title: MySQL all select rows in range
body: <p>I need some help retrieving data from rows in range.
  Let's say this is my table:</p>
  
  <p><a href="https://i.stack.imgur.com/GgXg9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GgXg9.png" alt="enter image description here"></a></p>
  
  <p>That's what I need:</p>
  
  <p>I need to sort the rows by ID and then get <strong>9</strong> rows, where the <strong>gameID</strong> is <em>1</em> and <em>winner's</em> <strong>unique_id</strong> must be in the middle.
  For example:</p>
  
  <pre><code>$gameID = 1;
  $winner = "iii";
  </code></pre>
  
  <p>so it should return:</p>
  
  <pre><code>5.eee
  6.fff
  7.ggg
  8.hhh
  9.iii &lt;--- winner in the middle
  10.jjj
  11.kkk
  12.lll
  13.mmm
  </code></pre>
  
  <p>How can I achieve this result?</p>
  
  <p>Thanks.</p>
  
  <p>EDIT:</p>
  
  <pre><code>$b = $db-&gt;query("SELECT * FROM test WHERE gameID = 1 AND unique_id = 'iii'");
  $res = $b-&gt;fetch();
  $winnerID = $res['ID'];
  $b2 = $db-&gt;query("SELECT * FROM test WHERE ID BETWEEN $winnerID-4 AND $winnerID+4 ORDER BY ID ASC");
  $data = $b2-&gt;fetchAll();
  </code></pre>
  
  <p>This works, but I was wondering if it's possible in a single row.</p>