title: How to find threads only posted by friends?
body: <p>So, I have a majority of my SQL query done. However, I can't seem to figure out how select threads that were only posted by the users friends.</p>
  
  <p>Here's my current query that works:</p>
  
  <pre><code>SELECT social_posts.message, social_posts.post_stamp, user.username, user.id, user.default_picture
  FROM social_threads
  JOIN social_posts ON social_posts.thread_id = social_threads.id
  LEFT JOIN user ON user.id = social_threads.user_id
  ORDER BY social_threads.id DESC
  </code></pre>
  
  <p>Here's the <code>friends</code> table:    </p>
  
  <pre><code>*----*--------*--------*---------*
  | id | user_a | user_b | request | 
  *----*--------*--------*---------*
  | 1  | 3      | 5      | 1       |
  *----*--------*--------*---------*
  </code></pre>
  
  <p><code>request</code> set to one means the friend request was accepted.</p>
  
  <p>The where clause in the query would have to look something like this:</p>
  
  <pre><code>WHERE ((friends.user_a = '3' || friends.user_b = '3') &amp;&amp; friends.request = '1') || (social_threads.user_id = '3')
  </code></pre>
  
  <p>I just need to figure out how to get that where clause in the main query.</p>
  
  <p>Any help is greatly appreciated.</p>