title: Access DB: TOP clause and nested queries + PHP Paging
body: <p>I'm developing a PHP interface to show some results from two different databases: a MySQL one (.sql) and an Access one (.mdb). When I query for the results I let the user choose how many of them he wants to list, so that I can limit and page them through some PHP fun.<br>
  This is flawlessly working for the MySQL DB, where the <strong>LIMIT</strong> clause does everything in a neat way. The Access DB is a different talk: Access doesn't have a LIMIT clause, so that I've to use the <strong>TOP</strong> clause. Too bad that this one makes paging a pain in the back.<br>
  I've found a nice example in the accepted answer to <a href="https://stackoverflow.com/questions/24212290/access-2010-limit-query-results?noredirect=1&amp;lq=1">this question</a>, but I'm having an issue. First of all, let me show you a couple of snippet queries:</p>
  
  <p><strong>QUERY #1</strong></p>
  
  <pre><code>SELECT TOP 5 *                 
  FROM `Table_1` INNER JOIN `Table_2`
  ON `Table_1`.`Some_ID` = `Table_2`.`Some_ID`
  AND `Table_1`.`Timestamp` = `Table_2`.`Timestamp`
  WHERE `Table_1`.`Some_ID` LIKE 'ID %' AND `Table_1`.`Timestamp` LIKE '2018/03/20 %';
  </code></pre>
  
  <p><strong>QUERY #2</strong></p>
  
  <pre><code>SELECT TOP 5 *                 
  FROM `Table_1` INNER JOIN `Table_2`
  ON `Table_1`.`Some_ID` = `Table_2`.`Some_ID`
  AND `Table_1`.`Timestamp` = `Table_2`.`Timestamp`
  WHERE `Table_1`.`Some_ID` LIKE 'ID %' AND `Table_1`.`Timestamp` LIKE '2018/03/20 %'
  ORDER BY `Table_1`.`Some_ID`;
  </code></pre>
  
  <p><strong>Query #1</strong> shows me just the first 5 results, as asked.<br>
  Too bad that, when I add an <strong>ORDER BY</strong> clause, <strong>Query #2</strong> gives me back ALL the results satisfying my conditions.  </p>
  
  <p>The same thing doesn't happen with a MySQL query like this:</p>
  
  <p><strong>QUERY #3</strong></p>
  
  <pre><code>SELECT * 
  FROM `Table_1` INNER JOIN `Table_2`
  ON `Table_1`.`Some_ID` = `Table_2`.`Some_ID` 
  AND `Table_1`.`Timestamp` = `Table_2`.`Timestamp` 
  WHERE `Table_1`.`Some_ID` LIKE 'ID %' AND `Table_1`.`Timestamp` LIKE '2018/03/20 %'
  ORDER BY `Table_1`.`Some_ID`
  LIMIT 0, 5;
  </code></pre>
  
  <p>So, am I doing something wrong with my Access query?<br>
  To complete my question, this is how my final Access query should look like (I've slightly modified the one proposed in the aforementioned topic):</p>
  
  <p><strong>QUERY #4</strong></p>
  
  <pre><code>SELECT * 
  FROM `Table_1` INNER JOIN `Table_2` 
  ON `Table_1`.`Some_ID` = `Table_2`.`Some_ID` 
  AND `Table_1`.`Timestamp` = `Table_2`.`Timestamp` 
  WHERE EXISTS (
      SELECT TOP 5 * FROM (
          SELECT TOP 10 * 
          FROM `Table_1` INNER JOIN `Table_2` 
          ON `Table_1`.`Some_ID` = `Table_2`.`Some_ID` 
          AND `Table_1`.`Timestamp` = `Table_2`.`Timestamp` 
          WHERE `Table_1`.`Some_ID` LIKE 'ID %' AND `Table_1`.`Timestamp` LIKE '2018/03/20 %') 
      ORDER BY `Table_1`.`Some_ID` DESC) 
  ORDER BY `Table_1`.`Some_ID` ASC;
  </code></pre>