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

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -