title: MySQL wrong count value when left join
body: <p>I'm not sure what I'm doing wrong here. </p>
  
  <p>This Works and produces desired results
  (Get a list of recipes and the total amount of rating in the ratings table)</p>
  
  <pre><code>SELECT recipes.RecipeID, 
         recipes.Name, 
         recipes.RatingTotal, 
         recipes.ImageBig, 
         users.Email, 
         users.FullName, 
         users.UserImageBig, 
         COUNT(ratings.RecipeID) AS trates 
  FROM   recipes 
         LEFT JOIN users 
                ON recipes.User = users.Email 
         LEFT JOIN ratings 
                ON ratings.RecipeID = recipes.RecipeID 
  GROUP  BY RecipeID 
  ORDER  BY RecipeID DESC 
  LIMIT  3 
  </code></pre>
  
  <p>This Does not work
  (Get a list of recipes and the total amount of rating in the ratings table and the total number of comments as well. the query runs but the values are wrong in the count columns)</p>
  
  <pre><code>SELECT recipes.RecipeID, 
         recipes.Name, 
         recipes.RatingTotal, 
         recipes.ImageBig, 
         users.Email, 
         users.FullName, 
         users.UserImageBig, 
         COUNT(ratings.RecipeID)        AS trates, 
         COUNT(recipecomments.RecipeID) AS crate 
  FROM   recipes 
         LEFT JOIN users 
                ON recipes.User = users.Email 
         LEFT JOIN ratings 
                ON ratings.RecipeID = recipes.RecipeID 
         LEFT JOIN recipecomments 
                ON recipecomments.RecipeID = recipes.RecipeID 
  GROUP  BY RecipeID 
  ORDER  BY RecipeID DESC 
  LIMIT  3 
  </code></pre>
  
  <p>If there are 2 comments, it returns 4 double of the actual number. Also ratings will become 4.</p>