0

I am new to databases and I was given a task at work to improve an open source system that's been designed by someone else.

What I tried so far is:

select r.id, r.room_name, e.type,max(e.start_time) as st, max(e.end_time) as et ,max(e.timestamp) as updt
from mrbs_room r 
join mrbs_entry e on r.id=e.room_id 
where r.area_id=1 and r.disabled=0 
group by r.id
order by r.room_name DESC;

Snapshot of result:

query

The last field (Name) records results are not matching the database records.

What am I doing wrong?

halfer
  • 19,824
  • 17
  • 99
  • 186
  • 1
    Possible duplicate of [MySQL join with where clause](https://stackoverflow.com/questions/1219909/mysql-join-with-where-clause) – Alexander Apr 24 '18 at 03:47
  • Hi there. Please read [Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers?](//meta.stackoverflow.com/q/326569) - the summary is that this is not an ideal way to address volunteers, and is probably counterproductive to obtaining answers. Please refrain from adding this to your questions. – halfer Apr 24 '18 at 09:07
  • Also, a number of folks in our community sometimes say that every time they see gendered assumptions about software engineers, they worry about people feeling excluded. I wonder, could you try to avoid adding male-oriented greetings and pronouns in your posts, so as to make for a more welcoming environment? Thank you. – halfer Apr 24 '18 at 09:07
  • The query in your image, and the text query provided, are not the same: there is no `max(e.name) as name` in the text version. – halfer Apr 24 '18 at 09:10

0 Answers0