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:
$query = "SELECT *, COUNT(*) as total WHERE IMAGE != '' AND CATEGORY = '$category' $limit";
But this outputs a single row when done... :(
Than I have tried:
$query = "SELECT * FROM PRODUCTS,
(SELECT COUNT(*) as total FROM PRODUCTS WHERE IMAGE != '' AND CATEGORY = '$category') as x
WHERE IMAGE != '' AND CATEGORY = '$category' $limit";
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).
Is there a better way? Thanks