Query to find out the last message from all users in conversation
select messages.message_text, messages.sender_uuid, messages.receiver_uuid, messages.add_date FROM messagesINNER JOIN (
SELECT MAX(add_date) AS time, IF(`receiver_uuid` = '1', `sender_uuid`, `receiver_uuid`) AS user FROM dp_messages GROUP BY user) m2
ON messages .add_date = m2.time
AND (messages .`sender_uuid` = m2.user OR dp_messages .`receiver_uuid` = m2.user)
WHERE
`sender_uuid` = '1' OR `receiver_uuid` = '1'
ORDER BY messages .add_date DESC LIMIT 0, 20