SELECT * FROM ...LIMIT 5, 10
But what if I want the total rows? I don't want to make another query without the limit. I just want this one query to return the total rows if I didn't put the LIMIT in there.
SELECT * FROM ...LIMIT 5, 10
But what if I want the total rows? I don't want to make another query without the limit. I just want this one query to return the total rows if I didn't put the LIMIT in there.
the only way is like this (use 2 queries):
SELECT SQL_CALC_FOUND_ROWS ..... FROM table WHERE ... LIMIT 5, 10;
and right after run this :
SELECT FOUND_ROWS();
read more :
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