MySql order by problem
Posted
by Sergio
on Stack Overflow
See other posts from Stack Overflow
or by Sergio
Published on 2010-03-13T00:14:43Z
Indexed on
2010/03/13
0:17 UTC
Read the original article
Hit count: 617
mysql
Hello.
I want to list messages that received specific user from other users group by ID's and ordered by last message received.
If I use this query:
SELECT MAX(id), fromid, toid, message FROM pro_messages WHERE toid=00003 GROUP BY
fromid
I do not get last message sent from user "fromid" to user "toid" but the first message sent. Can I do that in some other way or I need to do it with two queries or join tables?
id - message id fromid - id of user who sent message toid - id of user who receive message (in this case user 00003)
© Stack Overflow or respective owner