title: Count likes of each user using two tables
body: <p>I have two tables, the first one is <code>POSTS</code>that has three fields (<code>post_id</code>, <code>user_id</code>, <code>text</code>) the second table is <code>LIKES</code> has two fields (<code>user_id</code>, <code>post_id</code>) <code>likes.user_id</code> is the id of the user who liked the post. </p>
  
  <p>Now I want to query the database and get the count of likes (distance) of each user to another. Meaning I'd get a result of three fields, four with the index (I'm not too worried about it for now):</p>
  
  <pre><code>User 1 | User 2 | count(INT) | index
  -------------------------------------
  User_a | User_b |     45     | ab
  User_c | User_n |     53     | cn
  User_b | User_a |     38     | ba
  </code></pre>
  
  <p>I tried using something like this, but I'm not always getting an accurate number of likes. Also, I'm getting some data redundancy.</p>
  
  <pre><code>SELECT likes.user_id, posts.user_id,
  COUNT(likes.post_id)
  from posts, likes
  WHERE posts.post_id = likes.post_id
  GROUP BY posts.user_id
  ORDER BY COUNT(likes.post_id)
  </code></pre>
  
  <p><strong>I'm a MySQL rookie, so excuse any errors!, Thank you for any help!</strong></p>