SELECT `user`,`message`,`date`,`read`,`attach`,`name`
FROM user_dialog d
JOIN user u
ON u.id = d.why
WHERE (d.user = 1)
GROUP BY `user`
SELECT DISTINCT IF(sender_id > recipient_id, sender_id, recipient_id) id1, IF(sender_id < recipient_id, sender_id, recipient_id) id2 FROM dialog