title: Grouped JOIN query in MySQL - using the ON vs. HAVING condition for filtering (any difference?)
body: <p>Following are pseudo queries so I don't care about the results, but is there any sort of difference (in performance, result amount etc.) between the following MySQL queries?</p>
  
  <p><strong>Query 1</strong></p>
  
  <pre><code>SELECT u.`username`, COUNT(*) AS 'posts', u.`age`
  FROM `users` u
  INNER JOIN `posts` p
  ON p.`user_id`=u.`id`
  GROUP BY u.`id`
  HAVING u.`age` &gt; 12
  </code></pre>
  
  <p>Suppose that the column <code>smth</code> in this query is selected only for the sake of <code>HAVING</code> conditon, so its value is not needed in the results.</p>
  
  <p><strong>Query 2</strong></p>
  
  <pre><code>SELECT u.`username`, COUNT(*) AS 'posts'
  FROM `users` u
  INNER JOIN `posts` p
  ON p.`user_id`=u.`id` AND u.`age` &gt; 12
  GROUP BY u.`id`
  </code></pre>