title: Select and count rows in the same query?
body: <p>I am trying to find a way to select and count some rows in my database. I was checking the MySQL docs and this is what I came up with:</p>
  
  <pre><code>$query = "SELECT *, COUNT(*) as total WHERE IMAGE != '' AND CATEGORY = '$category' $limit";
  </code></pre>
  
  <p>But this outputs a single row when done... :(</p>
  
  <p>Than I have tried:</p>
  
  <pre><code>$query = "SELECT * FROM PRODUCTS,
          (SELECT COUNT(*) as total FROM PRODUCTS WHERE IMAGE != '' AND CATEGORY = '$category') as x
          WHERE IMAGE != '' AND CATEGORY = '$category' $limit";
  </code></pre>
  
  <p>This works, however I don't really know if this will perform well, because of the two SELECT statements (lus I don't need 'as x', but without this the query fails).</p>
  
  <p>Is there a better way?
  Thanks</p>