title: How to return count of sub-query results as column in mysql
body: <p>I have a table called users with a primary key called user_id for each user.</p>
  
  <p>I have another table called friends which link users to other users as friends.</p>
  
  <p>This friends table has two columns user_id and friend_id. The user_id column is always the lower of the two user_id's in order to prevent duplicates.</p>
  
  <p>I want to do a query to get all the fields from the users table, but also return how many mutual friends a user has with another user as a count in another column called mutual_friends_count.</p>
  
  <p>So basically if i wanted to know how many mututal friends each user has in common with user_id 5, the query would select all from the users table and for each user do a subquery to find the mutual friends and return the count as mutual_friends_count</p>