Here is the schema of my DB:
id | user1 | user2 | status //status 1 means the user is a friend
1 1 2 1
2 3 1 1
3 1 4 1
4 2 3 1
5 4 2 1
In the above example
- userId 1 has 3 friends 2,3,4
- userId 2 has 3 friends ie. 3,4,1
- userId 3 has 2 friends ie: 1,2
- userId 4 has 2 friends ie:1,2
I need to find mutual friends between 2 people.
Any Ideas,
I am not really sure if this is the best solution. But maybe something like this:
This gets the mutual friends from user 1 and 2. Which is 3,4