Home > Database > Mysql Tutorial > How to query the number of data in mysql

How to query the number of data in mysql

青灯夜游
Release: 2022-06-21 18:00:28
Original
6114 people have browsed it

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.

How to query the number of data in mysql

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 初始位置;
Copy after login

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;
Copy after login

How to query the number of data in mysql

Query the second piece of data

SELECT * FROM tb_students_score LIMIT 1,1;
Copy after login

How to query the number of data in mysql

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;
Copy after login

How to query the number of data in mysql

[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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template