title: select friends of friends mysql
body: <p>I have two tables:</p>
  
  <pre><code>**user**
  -id
  -first_name
  
  **friends**
  -id
  -user_id
  -friend_id
  </code></pre>
  
  <p>so, table 'users' have</p>
  
  <pre><code>'id'  'first_name'
   1      name_1         
   2      name_2         
   3      name_2        
  </code></pre>
  
  <p>and 'friends'</p>
  
  <pre><code>'id'  'user_id'  'friend_id'
   1      1           2
   2      2           3
   3      3           4
   4      3           5
  </code></pre>
  
  <p>So I need to get 'suggested' friends, friends of friends who is not directly my friends from <code>users table</code>.</p>
  
  <p>I tried something like this </p>
  
  <pre><code>select distinct users.id
  from friends a
  join friends b on b.user_id = a.friend_id
  join users on users.id = b.friend_id 
  where user.id = 3
  </code></pre>