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:
SELECT FOUND_ROWS();
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.
http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_found-rows
Latest news
- - S5 Slide Show System: PowerPoint on Linux
- - µTorrent for Linux
- - Linux audio tagger
- - Gnome 3 release date - interview with Stormy Peters
- - Ubuntu Maverick Meerkat Beta Released
- - Ubuntu Maverick Meerkat frozen
- - Tab Candy for Firefox
- - Ubuntu font launched for beta testing
- - Interview with Richard Stallman
- - Linux Mint 9 KDE released
- - Gnome 3 release date delayed to march 2011