title: mysql: multiple join problem
body: <p>Im trying to select a table with multiple joins, one for the number of comments using COUNT and one to select the total vote value using SUM, the problem is that the two joins affect each other, instead of showing:</p>
  
  <p>3 votes 2 comments</p>
  
  <p>I get 3 * 2 = 6 votes and 2 * 3 comments</p>
  
  <p>This is the query I'm using:</p>
  
  <pre><code>SELECT t.*, COUNT(c.id) as comments, COALESCE(SUM(v.vote), 0) as votes
  FROM (topics t)
  LEFT JOIN comments c ON c.topic_id = t.id
  LEFT JOIN votes v ON v.topic_id = t.id
  WHERE t.id = 9
  </code></pre>