user, chat_room and message
the table message have foreign key from tables chat_room and user
the system consists in a simple chat room
the query must return the last row of each user from a specific chat_room
I'm trying this way
select u.id, u.nick, m.messageHour
from user u
inner join message m on u.id = m.id_user
inner join chat_room c on m.id_chat_room = c.id
where c.id = 148 && u.active = true && u.id <> 1
group by m.id_user
order by c.messageHour desc
but unfortunately, the query is returning the FIRST row of each user and i need the LAST
Does someone knows a way to do this? thanks a lot