title: MySql, limint number of articles in each category
body: <p>I'm trying to create simple news site, and on home page I want to display all categories, and limit number of article in each category to 5. This is what I got so far.</p>
  
  <p>table categories</p>
  
  <pre><code>id    name    
  ========================================
  1    World
  2    Sports
  3    Economy
  4    Music
  </code></pre>
  
  <p>table artices</p>
  
  <pre><code>id   category_id  name  
  ===============================
  1    1            Article 1
  2    1            Article 2
  3    1            Article 3
  4    2            Article 11
  5    2            Article 22
  6    3            Article 33
  7    4            Article 111
  8    3            Article 222
  9    3            Article 333
  </code></pre>
  
  <p>and my query:</p>
  
  <pre><code>SELECT
    a.category_id,
    c.name as catname,
    a.name as artname
  FROM
    categories AS c
    LEFT JOIN articles AS a
      ON a.category_id = c.id
  LIMIT 5;
  </code></pre>
  
  <p>The problem is that limit is applied to categories table, but I actually need to apply to articles table.</p>