mysql - Get last post on each room with SQL -
i want able retrieve last post made user, on every room in application. however, query i've built, retrieving allways first one?
the tables this
rooms id|name|subname posts id|title|description|id_room|date_posted
what missing or doing wrong here?
select * rooms rm inner join posts pst on pst.id_room = rm.id pst.id = ( select max( pst.id ) posts ) group rm.id
thank you
something should better (your query retrieve max pst.id, not max pst.id room)
select * rooms rm inner join posts pst on pst.id_room = rm.id pst.id in (select max(pst.id) posts group pst.id_room)
simplified sqlfiddle, query , mine.
Comments
Post a Comment