Finding mutual friend sql
<p>actually i have 2 tables the friend table and the users table
what i try to achieve is to retreive my mutual friend by checking the friend of another user and get the data of these mutual friend from the users table</p>

<p>table friend is build like this </p>

<pre><code>id | user1 | user2 | friend_status
</code></pre>

<p>then the table data looks like this </p>

<pre><code>1 | 1 | 2 | 1
2 | 1 | 3 | 1
3 | 2 | 3 | 1
4 | 1 | 4 | 1
5 | 2 | 4 | 1
</code></pre>

<p>Then let's say that I am the user with id 2, then in that table I have 3 friends - 1, 3 and 4. What I want to retrieve are the common friends with user 1 that have also 3 friends - 2, 3 and 4 and retrieve the data from the table users for the 2 common mutual friend 3 and 4 </p>