I have MySQL table that contains all messages from user to user:
id | to_id /*user_id*/ | from_id /*user_id*/
1 | 32 | 54
2 | 54 | 32
3 | 32 | 54
The goal is get MySQL answer like list of dialogs user_id – user_id ordered by date. But if i do sql query:
select * from messages group by to_id, from_id
i will get
to_id /*user_id*/ | from_id /*user_id*/
32 | 54
54 | 32
But first and second string is the same dialog. How can i group this records?
1 Answer