Home  >  Article  >  Database  >  How to return the total number of queries in mysql

How to return the total number of queries in mysql

coldplay.xixi
coldplay.xixiOriginal
2020-11-03 14:45:256214browse

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.

How to return the total number of queries in mysql

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn