Home > Database > Mysql Tutorial > body text

How to query and count the quantity in mysql

青灯夜游
Release: 2021-12-10 17:55:42
Original
41548 people have browsed it

In mysql, you can use the SELECT statement to query data, and use the COUNT() function to count the number of query results. The syntax is "SELECT COUNT(*) FROM table name [...];" or "SELECT COUNT (field name) FROM table name[...];".

How to query and count the quantity in mysql

The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.

In mysql, you can use the SELECT statement to query data, and use the COUNT() function to count the number of query results. The syntax format of

SELECT is as follows:

SELECT
{* | <字段列名>}
[
FROM <表 1>, <表 2>…
[WHERE <表达式>
[GROUP BY 
[HAVING  [{ }…]]
[ORDER BY ]
[LIMIT[,] ]
]
Copy after login

Among them, the meaning of each clause is as follows: