Mysql returns the total number of queries: first open the terminal; then add modification [SQL_CALC_FOUND_ROWS] to the SELECT statement; finally execute [select SQL_CALC_FOUND_ROWS], and then take the total number of records.
Enter statement:
select * from auth_user SELECT FOUND_ROWS() //Returns the total number of query records select sql_calc_found_rows col_name from table_name limit 5,3; select found_rows()
Add modification SQL_CALC_FOUND_ROWS
After adding SQL_CALC_FOUND_ROWS to the SELECT statement, even if you use limit n,m, SELECT FOUND_ROWS()
will still return the total number of records satisfying the condition. In this way, after you execute select SQL_CALC_FOUND_ROWS
, just fetch the total number of records.
More related free learning recommendations: mysql tutorial (video)
The above is the detailed content of how mysql returns the total number of queries. For more information, please pay attention to 1024programmer. com Other related articles!