To get the most recent row of data by sender and receiver, you can use a self join as follows:
select *
from messages msg
where sent = (select max(sent)
from messages msg_
where msg_.fromperson = msg.fromperson
and msg_.toperson = msg.toperson)
0
solved MYSQL Select group by order by