title: MySQL pagination without double-querying?
body: <p>I was wondering if there was a way to get the number of results from a MySQL query, and at the same time limit the results.</p>
  <p>The way pagination works <em>(as I understand it)</em> is to first do something like:</p>
  <pre><code>query = SELECT COUNT(*) FROM `table` WHERE `some_condition`
  </code></pre>
  <p>After I get the <code>num_rows(query)</code>, I have the number of results. But then to actually limit my results, I have to do a second query:</p>
  <pre><code>query2 = SELECT COUNT(*) FROM `table` WHERE `some_condition` LIMIT 0, 10
  </code></pre>
  <p>Is there any way to both retrieve the total number of results that would be given, AND limit the results returned in a single query? Or are there any other efficient ways of achieving this?</p>