|
|
Use of SQL_CALC_FOUND_ROWS in Mysql - Mysql
|
Views : 1960
|
|
Tagged in : Mysql
|
|
|
Report This Scrap as Inappropriate We request you to choose the appropriate categroy and subcategory that suits your
objectionable concern about the scrap, So that our team can review and find out whether it violates our Guidelines or the
scrap is not suitable for all viewers.
|
A SELECT statement may include a LIMIT clause to restrict the number of rows the server returns to the client. In some cases, it is desirable to know how many rows the statement would have returned without the LIMIT, but without running the statement again. To obtain this row count, include a SQL_CALC_FOUND_ROWS option in the SELECT statement, and then invoke FOUND_ROWS() afterward:
mysql> SELECT SQL_CALC_FOUND_ROWS * FROM tbl_name
-> WHERE id > 100 LIMIT 10;
mysql> SELECT FOUND_ROWS();
The second SELECT returns a number indicating how many rows the first SELECT querywould have returned without the LIMIT clause ie it returns the total count.
In the absence of the SQL_CALC_FOUND_ROWS option , FOUND_ROWS() returns the number of rows in the result set returned by that statement ie it returns only 10.
|
|
By Rekha, On - 2009-01-03 |
|
|
|