I have this table (followers) in my database.
follower | following
---------|----------
1 |2
1 |4
1 |5
1 |6
1 |7
1 |8
2 |4
4 |6
This documents all of the followings and followers for my users. I have this query, which is not working.
SELECT following
FROM followers
WHERE follower
IN (SELECT following
FROM followers
WHERE follower = 2)
OR following IN (SELECT follower
FROM followers
WHERE following = 2)
What I am trying to achieve is a list of users followed by the users that the user "2" follows, merged with a list of users that follow the user "2". Excluding everyone already being followed by user "2". And arranged by how closely related to the user "2" they are.
Ideally, my data output would be this (but not automatically that order):
suggested_users
---------------
6
1
5
7
8
I am actually at a loss as to how to ask this question, but how do I get these results?