Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SET @me = 16;
- SELECT
- a.*,
- b.name
- FROM (
- SELECT *,IF(`from`=@me,`to`,`from`) AS OtherParty
- FROM msg_messages WHERE (`from`=@me or `to`=@me) ORDER BY `date` desc) AS a
- JOIN
- users AS b ON a.OtherParty=b.id
- GROUP BY OtherParty ORDER BY `date` desc;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement