Advertisement
Darksoul__

Untitled

May 5th, 2021
871
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.56 KB | None | 0 0
  1. SELECT friendID,FU.nickname,FU.image_url,mess_text,date_time
  2.     FROM friends F
  3.         JOIN users U
  4.             ON F.userID=U.userID
  5.         LEFT JOIN users FU
  6.             ON FU.userID=friendID
  7.         JOIN messages M
  8.             ON F.last_message=M.messageID
  9.     WHERE U.userID='$_SESSION[name]'
  10. UNION
  11. SELECT G.groupID,group_name,G.image_url,mess_text,date_time
  12.     FROM groups_users GU
  13.         JOIN users U
  14.             ON GU.userID=U.userID
  15.         LEFT JOIN groups G
  16.             ON GU.groupID=G.groupID
  17.         LEFT JOIN messages M
  18.             ON G.last_message=M.messageID
  19.     WHERE U.userID='$_SESSION[name]'
  20. ORDER BY date_time DESC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement