There is such a request:
SELECT * FROM (SELECT * FROM mess WHERE who='2' or whom='2' ORDER BY id DESC) as tmp GROUP BY who, whom ORDER BY id DESC
It makes a selection from the end of the table and as a result it turns out something like this:
id who whom 13 2 1 11 1 2 9 3 2 7 2 3 4 2 5
How now to make it so that only records remain without repetitions in who and whom, and with a large id. That is, in the end it should be like this:
id who whom 13 2 1 9 3 2 4 2 5
Maybe a little clumsy explained, if something is not clear, specify.