MySQL Forums
Forum List  »  Newbie

Re: query Selecting Last entry per computer for a group from two tables. Urgent Help please.
Posted by: Peter Brawley
Date: April 12, 2018 07:35PM

Some joins need explicit join syntax. Comma joins and explicit join syntax don't mix well in MySQL (see the manual page on joins). So always use explicit join syntax.

The latest timestamp per id on your conditions is given by ...

select r.id, max(e.timestamp) as latest
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;

Now you need the outer query to retrieve the other values associated with id and latest pairs from this query.



Edited 2 time(s). Last edit at 04/13/2018 09:10AM by Peter Brawley.

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.