title: How to use COUNT to get zero values with mysql?
body: <p>I read several questions about this issue on stackoverflow :
  It seems that COUNT should be used with the right Joining to display sums of every items, including the ones summing zero.</p>
  
  <p>I'm not really able to make it with my case, after several hours of headache...</p>
  
  <p>Well, I have 2 tables.
  The first one is called "words2", with a list of words.
  The second one is called "links2". It's linking together two words : idWord1 and idWord2.
  (There are no links linking together two identical words)</p>
  
  <p>For each word, I would like to know how many links are used, even if there is no link.</p>
  
  <p>This is my query :</p>
  
  <pre><code>SELECT *, COUNT(*) AS qty  
  FROM ( 
      SELECT *
      FROM words2
      LEFT OUTER JOIN links2 AS linksA ON words2.idWord = linksA.idWord1 
  
      UNION
  
      SELECT *
      FROM words2
      LEFT OUTER JOIN links2 AS linksB ON words2.idWord = linksB.idWord2
  ) AS tmp
  WHERE idUser = 3 AND linkType = 'individual'
  GROUP BY word ORDER BY word
  </code></pre>
  
  <p>It works fine unless I don't have any results for the unused words, which are not displayed.</p>
  
  <p>Thank you very much for your help!</p>