Find total number of rows for a mysql query which contains the LIMIT clause
Login into your mysql database with a mysql client.
Suppose you have the following query:
SELECT * FROM myTable WHERE id > 50 LIMIT 10;
But you need to know how many rows are without the LIMIT
Instead of running again this query:
SELECT COUNT(*) FROM myTable WHERE id > 50;
you may include a SQL_CALC_FOUND_ROWS option in your query:
SELECT SQL_CALC_FOUND_ROWS * FROM myTable WHERE id > 50 LIMIT 10;
Then perform another query:
The result of the last query will show the total number of rows of the first query without the LIMIT clause.
It is very useful for paginating search results.