Advertisement
mikjaer

Untitled

Mar 31st, 2017
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1.  
  2.  
  3. SET @me = 16;
  4. SELECT
  5. a.*,
  6. b.name
  7. FROM (
  8. SELECT *,IF(`from`=@me,`to`,`from`) AS OtherParty
  9. FROM msg_messages WHERE (`from`=@me or `to`=@me) ORDER BY `date` desc) AS a
  10. JOIN
  11. users AS b ON a.OtherParty=b.id
  12. GROUP BY OtherParty ORDER BY `date` desc;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement