title: ORDER BY and LIMIT in GROUP BY
body: <p>I'm trying to get a subset of records in a GROUP BY, I've seen a lot of crazy solutions out there, but they just seem too complicated, is there any more efficient way to do this.</p>
  
  <pre><code>SELECT user_id, GROUP_CONCAT(item_id ORDER BY `timestamp`) AS items 
  FROM wb_user_book_current_item GROUP BY user_id
  </code></pre>
  
  <p>So this will return me all the current items for all users which is okay so far.  But I only want the ten most recent items.  Adding <code>ORDER BY</code> to the <code>GROUP_CONCAT</code> helps, but it still doesn't give me the last ten records.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>If I do something like this and hard code the <code>user_id</code> then I can get the results I want for that one user, problem is combining it so that I don't need to hard code the <code>user_id</code> and can for instance just get <strong>ALL</strong> users last ten items</p>
  
  <pre><code>SELECT GROUP_CONCAT(cp2.item_id) AS items 
  FROM (SELECT cp.user_id, cp.item_id 
        FROM wb_user_book_current_item cp 
        WHERE cp.user_id=1 ORDER BY cp.`timestamp` 
        LIMIT 10) AS cp2 
  GROUP BY cp2.user_id
  </code></pre>