The below query I used to get all user IDs, who message me OR message by me. It's working well. But now I want to show the last user at the top. How to do it please?
SELECT s.user1,s.user2 FROM(
SELECT CASE WHEN t.mfrom > t.mto THEN t.mfrom ELSE t.mto END as user1,
CASE WHEN t.mfrom < t.mto THEN t.mfrom ELSE t.mto END as user2
FROM messager t WHERE t.mfrom = '$ownid' OR t.mto='$ownid' ORDER BY t.date DESC) s GROUP BY s.user1,s.user2