How to choose count () and LIMIT?

SELECT * FROM ...LIMIT 5, 10

But what if I need full lines? I do not want to make another request without restriction. I just want this one query to return full rows if I didn't put a LIMIT there.

+5
source share
2 answers

only way: (use 2 queries):

SELECT SQL_CALC_FOUND_ROWS ..... FROM table WHERE ...  LIMIT 5, 10;

and immediately after launch:

SELECT FOUND_ROWS();

more details:

http://www.arraystudio.com/as-workshop/mysql-get-total-number-of-rows-when-using-limit.html

http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_found-rows

+5
source

Using

select count (*) from table_name
-2
source

All Articles