title: MYSQL - LIMIT inside a range
body: <p>I have built a slider using AJAX for the results, and i have a little problem as follow:</p>
  
  <p>assuming a table with a set of <code>1 to 15</code> rows, but, i'm working only with the first 9 rows; in a <strong>1st stage</strong> i  <code>(SELECT * FROM table ORDER BY id DESC LIMIT 9)</code> and use the results to build navigation and for displaying the first group. </p>
  
  <p>Then in a <strong>2nd stage</strong> i'm querying theese 9 items, 3 each time from <strong>left</strong> so i <code>(SELECT * FROM table WHERE id &gt; '$1' ORDER BY id DESC LIMIT 3)</code> or <strong>right</strong> so i <code>(SELECT * FROM table WHERE id &lt; '$1' ORDER BY id DESC LIMIT 3)</code> where <code>$1</code> is the last item of each group so <code>(13 || 11 || 7)</code> from  <code>(15, 14, 13) || (12, 11, 10) || (9, 8, 7)</code>. </p>
  
  <p>Well, immagine to have a representation of above verbose explanation like below:</p>
  
  <pre><code>&lt;- [ 15 - 14 - 13 - 12 - 11 - 10 - 9 - 8 - 7 ] -&gt;
     [    15     ]  [    14     ]  [    13     ]
  </code></pre>
  
  <p>Ok, <strong>the problem is</strong> when the "right-query" reach the <code>last item: 7</code>, the results-set is <code>(6, 5, 4)</code> that obviously is correct but isn't in <strong>our range of 15 to 7</strong>, instead for my purpose it should return nothing. how i can do this with one SQL query?</p>
  
  <hr>
  
  <p>just for sake here is the slider <a href="http://clients.altervista.org/php5/news.php" rel="nofollow">demo</a> ( latest item to the right, using the right arrow, is out of range );
  <em>hope it is not too fuzzy question cause i had an hard time figuring out how to explain the problem. ;)</em></p>