title: Get X number of specific rows. Mysql query
body: <p>Say I have a database with two tables: "food", and "whatToEat". </p>
  
  <p>I query the "whatToEat" and find 3 rows: </p>
  
  <pre><code>id    Food     username
   1    Apple      John
   2    Banana     John
   3    Milk       Linda
  </code></pre>
  
  <p>If I want to get those from the "food" table, I can just do something like this i guess: </p>
  
  <pre><code>SELECT * 
    FROM food 
   WHERE username='John' AND typeOfFood = 'apple' 
      OR typeOfFood = 'Banana' OR typeOfFood = 'Milk'
  </code></pre>
  
  <p>... but is it possible to dynamically write this, since the "whatToEat" table will change all the time, or do I need a loop and query the "food" table one by one for each of the objects in "whatToEat"? </p>
  
  <p>EDIT</p>
  
  <p>The above is just an example, the real scenario is an online game. When it's a players turn in a game, he's put on the "matches_updated" table. This table just holds his name, and the id of the match (or matches since he can be in several at the same time). When a player recive an update, I would like to check if he have any matches that needs to be updated (query "matches_updated" table), and then pull the data and return to him from the "matches" table, where all the information is stored about the matches. </p>
  
  <p>Example:</p>
  
  <p>The player Tim query the "mathces_updated" table and find he have 2 new matches that needs to be updated: </p>
  
  <pre><code>   match_id   username
      1          Tim
      2          Tim
      2          Lisa
      1           John
      3           John
  </code></pre>
  
  <p>... He now want to get the information about these matches, which is stored in the "matches" table: </p>
  
  <pre><code>match_id   match_status player1Name Player1Score Player2Name Player2Score
     1           1           John         123         Tim          12
     2           1           Lisa          4          Tim          15
     3           1           John          0          Lisa         0
  </code></pre>