title: Limit result amount for each ID to x
body: <p>I am trying to do something like this in MYSQL, but without making query multiple times (50 times, in my case) through a PHP foreach.</p>
  
  <pre><code>foreach($this-&gt;map_ids as $key =&gt; $val) {
      $this-&gt;db-&gt;query("SELECT scores.profile_number, scores.score  FROM scores 
                      LEFT JOIN players ON scores.profile_number = players.profile_number
                      WHERE scores.map_id = {'$val'}
                      AND scores.profile_number IN (SELECT profile_number FROM players WHERE banned = 0) LIMIT 10");    
  }
  </code></pre>
  
  <p>This is how it looks approximately when I retrieve all scores without LIMIT. </p>
  
  <pre><code>profile             score   map_id
  76561198026851335   2478    47455
  76561198043770492   2480    47455
  ...                 ...     ...
  76561198043899549   1340    47452
  76561198048179892   1345    47452
  ...                 ...     ...
  </code></pre>
  
  <p>I want only 10 entries (scores) from each unique map_id.</p>