title: Limit number of rows per id in a SQL query
body: <p>I want to limit the results of 10 products for each brand_id. Here's how my query looks like:</p>
  
  <pre><code>SELECT 
  products.id, products.brand_id
  FROM products
    JOIN (
      select id, brand_id
      from products limit 10) 
      pinner ON products.id = pinner.id
  WHERE pinner.brand_id IN ('1', '2','3') ;
  </code></pre>
  
  <p>That obviously does not work. Any suggestions?</p>
  
  <p><strong>EDIT:</strong>
  This post helped me with the solution: <a href="http://www.xaprb.com/blog/2006/12/07/how-to-select-the-firstleastmax-row-per-group-in-sql/" rel="nofollow">http://www.xaprb.com/blog/2006/12/07/how-to-select-the-firstleastmax-row-per-group-in-sql/</a></p>