title: How to limit a query by column value
body: <p>Following query...</p>
  
  <pre><code>SELECT event_id, user_id FROM EventUser WHERE user_id IN (1, 2)
  </code></pre>
  
  <p>...gives me the following result:</p>
  
  <pre><code>+----------+---------+
  | event_id | user_id |
  +----------+---------+
  |        3 |       1 |
  |        2 |       1 |
  |        1 |       1 |
  |        5 |       1 |
  |        4 |       1 |
  |        6 |       1 |
  |        4 |       2 |
  |        2 |       2 |
  |        1 |       2 |
  |        5 |       2 |
  +----------+---------+
  </code></pre>
  
  <p>Now, I want to modify the above query so that I only get for example two rows for each user_id, eg: </p>
  
  <pre><code>+----------+---------+
  | event_id | user_id |
  +----------+---------+
  |        3 |       1 |
  |        2 |       1 |
  |        4 |       2 |
  |        5 |       2 |
  +----------+---------+
  </code></pre>
  
  <p>I am thinking about something like this, which of course does not work:</p>
  
  <pre><code>SELECT event_id, user_id FROM EventUser WHERE user_id IN (1, 2) LIMIT 2 by user_id
  </code></pre>
  
  <p>Ideally, this should work with offsets as well because I want to use it for paginations.</p>
  
  <p>For performance reasons it is essential to use the <code>WHERE user_id IN (1, 2)</code> part of the query.</p>