mysql returns the total number of queries: first open the terminal; then add modification [SQL_CALC_FOUND_ROWS] to the SELECT statement; finally after executing [select SQL_CALC_FOUND_ROWS], take the total number of records.
mysql returns the total number of queries:
Input statement:
select * from auth_user SELECT FOUND_ROWS() //返回查询记录的总数 select sql_calc_found_rows col_name from table_name limit 5,3; select found_rows()
SELECT statement After adding modification SQL_CALC_FOUND_ROWS
After adding SQL_CALC_FOUND_ROWS, even if you use limit n,m, SELECT FOUND_ROWS()
will still return the total number of records that meet the conditions. In this way, after you execute select SQL_CALC_FOUND_ROWS
, just get the total number of records.
More related free learning recommendations: mysql tutorial(video)
The above is the detailed content of How to return the total number of queries in mysql. For more information, please follow other related articles on the PHP Chinese website!