MySQL - Return number of rows matching query data?

Posted by Keir Simmons on Stack Overflow See other posts from Stack Overflow or by Keir Simmons
Published on 2012-08-29T15:37:41Z Indexed on 2012/08/29 15:38 UTC
Read the original article Hit count: 225

Filed under:
|
|
|

I have a query as follows:

SELECT 1 FROM shop_inventory a JOIN shop_items b ON b.id=a.iid AND b.szbid=3362169 AND b.cid=a.cid WHERE a.cid=1 GROUP BY a.bought

The only thing I need to do with this data is work out the number of rows returned (which I could do with mysqli -> num_rows;. However, I would like to know if there is a method to return the number of rows that match the query, without having to run num_rows?

For example, the query should return one row, with one result, number_of_rows.

I hope this makes sense!

© Stack Overflow or respective owner

Related posts about mysql

Related posts about query