Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT me.uiD,
- their_friends.friend_id, me.username, me.photo,
- COUNT(*)
- FROM
- user AS me
- INNER JOIN
- user_friends AS my_friends
- ON my_friends.friend_one = me.uiD
- INNER JOIN
- user_friends AS their_friends
- ON their_friends.friend_two = my_friends.friend_id
- LEFT JOIN
- user_friends AS friends_with_me
- ON friends_with_me.friend_two = their_friends.friend_id
- AND friends_with_me.friend_one = me.uiD
- WHERE
- friends_with_me.friend_id IS NULL
- GROUP BY
- me.uiD,
- their_friends.friend_id;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement