title: MySQL count column values equal to another column
body: <p>I have a MySQL table like this:</p>
  
  <pre><code>Id  Id_1    Id_2
  1     0   0
  2     0   0
  3     1   0
  4     1   0
  5     0   0
  6     0   1
  7     2   1
  8     0   2
  </code></pre>
  
  <p>where Id_1 and Id_2 could be equal to Id except for itself or equal to 0</p>
  
  <p>and I would like to get this result by using the most efficient query:</p>
  
  <pre><code>id    COUNT(Id_1)   COUNT(Id_2)
  1         2             2
  2         1             1
  3         0             0
  4         0             0
  5         0             0
  6         0             0
  7         0             0
  8         0             0
  </code></pre>
  
  <p>Thanks!</p>