title: Twitter style following-follower table in SQL
body: <p>I have a basic follower/following table in mySQL which looks like this.</p>
  
  <pre><code>id      user_id     follower_id
  1           userA       userB
  2           userC       userA
  3           userA       userC
  4           userB       userC
  5           userB       userA
  </code></pre>
  
  <p>I checked these topics but couldnt find what I need</p>
  
  <p><a href="https://stackoverflow.com/questions/4895809/database-design-for-followers-and-followings">database design for &#39;followers&#39; and &#39;followings&#39;?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/15495570/sql-following-and-followers">SQL Following and Followers</a></p>
  
  <p>What I need is to have a system like this:</p>
  
  <p>Assume we are userB ( we follow userA, we are followed by userC and userA)</p>
  
  <p>I like to return a result that includes this follower/following state. For example for userB:</p>
  
  <pre><code>id      followedBy     areWeFollowing
  1           userA       1
  2           userC       0
  </code></pre>
  
  <p>Thanks for your help!</p>
  
  <p>arda</p>