Advertisement
Guest User

MySQL QUERY

a guest
Sep 8th, 2013
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. SELECT me.uiD,
  2. their_friends.friend_id, me.username, me.photo,
  3. COUNT(*)
  4. FROM
  5. user AS me
  6. INNER JOIN
  7. user_friends AS my_friends
  8. ON my_friends.friend_one = me.uiD
  9. INNER JOIN
  10. user_friends AS their_friends
  11. ON their_friends.friend_two = my_friends.friend_id
  12. LEFT JOIN
  13. user_friends AS friends_with_me
  14. ON friends_with_me.friend_two = their_friends.friend_id
  15. AND friends_with_me.friend_one = me.uiD
  16. WHERE
  17. friends_with_me.friend_id IS NULL
  18. GROUP BY
  19. me.uiD,
  20. their_friends.friend_id;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement