How to find out the total number of results in MySQL with a LIMIT query
Select * from table where a=1 limit 5,10
and the total number of rows with where a=1, for example, 50
how do I find out that it's 50?
either with two queries or with one
SELECT SQL_CALC_FOUND_ROWS * from table where a=1 limit 5,10
SELECT FOUND_ROWS();
or with one query you can do it like this,3 but probably it's not such a good idea
SELECT SQL_CALC_FOUND_ROWS *, FOUND_ROWS() as count_total from table where a=1 limit 5,10
Comments