title: MySQL left join excludes non-matching records?
body: <p>When I execute this MySQL query, I get correct results as expected:</p>
  
  <pre><code>select h.ID AS ProductID, h.ProductTitle, u.Username, ht.ProductType, hd.Difficulty-- , ifnull(sum(pv.UpVote),0) - ifnull(sum(pv.DownVote),0) AS NetVotes
  from Products h 
  join Users u on h.UserID = u.ID 
  join ProductTypes ht on h.ProductTypeID = ht.ID 
  join ProductDifficulties hd 
  on h.ProductDifficultyID = hd.ID 
  -- left join ProductVotes pv
  -- on h.ID = pv.ProductID
  </code></pre>
  
  <p>Notice I commented out the last column in the select (aggregate) and the left join. But when I include everything in the sql, ONLY records that have a matching ProductVotes record get included:</p>
  
  <pre><code>select h.ID AS ProductID, h.ProductTitle, u.Username, ht.ProductType, hd.Difficulty, ifnull(sum(pv.UpVote),0) - ifnull(sum(pv.DownVote),0) AS NetVotes
  from Products h 
  join Users u on h.UserID = u.ID 
  join ProductTypes ht on h.ProductTypeID = ht.ID 
  join ProductDifficulties hd 
  on h.ProductDifficultyID = hd.ID 
  left join ProductVotes pv
  on h.ID = pv.ProductID
  </code></pre>
  
  <p>I would expect this behavior from an inner join, but not a left join. Why is the left join excluding records without a matching ProductVotes record? And how can I have those included, just like in the first query above?</p>
  
  <p>EDIT: Originally I had a <code>LIMIT 0, 10</code> at the end of my query, and some folks thought this was causing the problem. I removed the limit clause and the problem still remains, so that had nothing to do with it. Now I have removed the <code>LIMIT</code> clause from my original post because it's irrelevant. Still awaiting an answer. :-)</p>
  
  <p>Here are the full results of <code>select * from ProductVotes</code>:</p>
  
  <pre><code>ID ProductID UserID UpVote DownVote
   2         1      2      1 NULL
   3         1      3      1 NULL
   4         1      4      1 NULL
   5         1      5      1 NULL
   6         1      6      1 NULL
   7         1      7      1 NULL
   8         1      8      1 NULL
   9         1      9   NULL    1
  10         1     10   NULL    1
  22         1      1      1 NULL
  </code></pre>
  
  <p>(Notice only 10 records in the table.)</p>
  
  <p><strong>IMPORTANT: Please notice the aggregations in my select statements: <code>ifnull(sum(pv.UpVote),0) - ifnull(sum(pv.DownVote),0) AS NetVotes</code></strong></p>