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 is producing the correct results however they are not in the correct order.
The grouping works well but it record displayed in the group is the first recorded entered into the DB but I would like the latest record to be displayed in each group.
Is there a way to have the latest record displayed 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 that is the most recent record/message.
Cheers