title: categories for each data in database by a specific id and only allow get 2 for each categories mysql
body: <p>Possible duplicated <a href="https://stackoverflow.com/questions/3140589/mysql-query-select-top-3-rows-from-table-for-each-category">MySql Query: Select top 3 rows from table for each category</a>. I'm not clear with that answer that why I asked a again.</p>
  
  <p>This is my database</p>
  
  <pre><code>+-------+----------+-------------+
  |  id   |  app_Id  |   Content   |
  +-------+----------+-------------+
  |   1   |    19    | Hello Peer  |
  +-------+----------+-------------+
  |   2   |    20    | Hello Peer  |
  +-------+----------+-------------+
  |   3   |    19    | Hello Peer  |
  +-------+----------+-------------+
  |   4   |    19    | Hello Peer  |
  +-------+----------+-------------+
  |   5   |    21    | Hello Peer  |
  +-------+----------+-------------+
  |   6   |    20    | Hello Peer  |
  +-------+----------+-------------+
  |   7   |    19    | Hello Peer  |
  +-------+----------+-------------+
  |   8   |    20    | Hello Peer  |
  +-------+----------+-------------+
  |   9   |    21    | Hello Peer  |
  +-------+----------+-------------+
  </code></pre>
  
  <p>Now how can I select the record categories by the app_Id and limit 2 for each categories and order by appId desc</p>
  
  <p>If the statement above not clear.Here is my expected output record from the database above.</p>
  
  <pre><code>+-------+----------+-------------+
  |  id   |  app_Id  |   Content   |
  +-------+----------+-------------+
  |   4   |    19    | Hello Peer  |
  +-------+----------+-------------+
  |   7   |    19    | Hello Peer  |
  +-------+----------+-------------+
  |   6   |    20    | Hello Peer  |
  +-------+----------+-------------+
  |   8   |    20    | Hello Peer  |
  +-------+----------+-------------+
  |   5   |    21    | Hello Peer  |
  +-------+----------+-------------+
  |   9   |    21    | Hello Peer  |
  +-------+----------+-------------+
  </code></pre>
  
  <p>I want the query to do this any idea?</p>