You want retrieve 10 results at a time, but at the same time you want to display total rows count?

SELECT SQL_CALC_FOUND_ROWS column_name FROM table_name LIMIT 1,10; SELECT FOUND_ROWS();

The second query (COUNT() is never used) will tell you how many results there are total, so you can display a phrase “Found 20000 results, displaying 1-10”. Note that FOUND_ROWS does not pay attention to the LIMITs you specified and always returns the total number of rows affected by query.

Leave a Reply

Your email address will not be published. Required fields are marked *