In mysql, you can use the SELECT statement with the LIMIT clause to query. The syntax is "SELECT *|field name list FROM table name LIMIT initial position, number of records;" or "SELECT *|field name list FROM Table name LIMIT record number OFFSET initial position;". The LIMIT clause can specify which record the query results should start displaying from and how many records should be displayed; "initial position" indicates which record should start displaying, and "number of records" indicates the number of records to be displayed.
The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.
In mysql, you can use the SELECT statement with the LIMIT clause to query the specified piece of data starting from the specified number of rows.
There are two syntaxes:
SELECT *|字段名列表 FROM 表名 LIMIT 初始位置,记录数; SELECT *|字段名列表 FROM 表名 LIMIT 记录数 OFFSET 初始位置;
Among them, "initial position" indicates which record to start displaying; "number of records" indicates the number of displayed records. The first record is at position 0 and the second record is at position 1. The subsequent records are deduced in sequence.
Note: The two parameters after LIMIT must be positive integers.
Example:
There is a tb_students_score table, query all the data in it
SELECT * FROM tb_students_score;
Query the second piece of data
SELECT * FROM tb_students_score LIMIT 1,1;
Query the 2 data starting from the third piece, that is, the 3rd and 4th piece of data
SELECT * FROM tb_students_score LIMIT 2,2;
[Related recommendations:mysql video tutorial]
The above is the detailed content of How to query the number of data in mysql. For more information, please follow other related articles on the PHP Chinese website!