I have a mysql statement
SELECT * FROM tbl_messages WHERE to_user_id = '$user_id' OR from_user_id = '$user_id' GROUP BY from_user_id ORDER BY date_sent DESC
and it produces the correct results, but they are not in the correct order.
Grouping works well, but the record displayed in the group is the first record entered in the database, but I would like the last record to be displayed in each group.
Is there a way to display the last record for each group?
2011-12-19 12:16:25 This is the first message 2011-12-19 12:18:20 This is the second message 2011-12-19 12:43:04 This is the third message
The group shows “This is the first message,” where I would like “This is the third message,” as this is the most recent post / message.
Greetings
mysql sql-order-by group-by
puks1978
source share