title: Group by, having using in MySQL
body: <p>I have problem with mysql query.
  I need get full rows with max value rating.
   For example I have table <strong>recipes</strong></p>
  
  <p><strong>rating     |    id      |   class</strong></p>
  
  <pre><code>4.1  | 1 | soup
  4.2 | 3 | soup
  4.9 | 4 | soup
  4.8 | 5 | salads
  4.3 | 6 | dishes9
  
  SELECT MAX(rating) rat, id, class FROM recipes GROUP BY class
  </code></pre>
  
  <p>And I get result:</p>
  
  <p><strong>rat     |    id      |   class</strong></p>
  
  <pre><code>4.9 | 1 | soup
  4.8 | 5 | salads
  4.3 | 6 | dishes
  </code></pre>
  
  <p>So in first row(where class='soup') I get  trully max rating - 4.9, but in this row id has value 1, not 4.</p>
  
  <p>When I use <strong>having</strong></p>
  
  <pre><code>SELECT MAX(rating) rat, id, class FROM recipes GROUP BY class HAVING rating=rat
  </code></pre>
  
  <p>result become</p>
  
  <p><strong>rat     |    id      |   class</strong></p>
  
  <pre><code>4.8 | 5 | salads
  4.3 | 6 | dishes
  </code></pre>
  
  <p>Can anyone help me with this problem?</p>