Home > Database > Mysql Tutorial > body text

How can we count the number of rows in a table using MySQL SELECT statement?

王林
Release: 2023-08-26 10:21:14
forward
1374 people have browsed it

我们如何使用 MySQL SELECT 语句来统计表中的行数?

We need to use the COUNT(*) function and the SELECT clause to count the total number of rows in the table.

Example

mysql> Select COUNT(*) from Student;

+----------+
| COUNT(*) |
+----------+
| 4        |
+----------+

1 row in set (0.06 sec)
Copy after login

The above query calculates the total number of rows in the "Student" table.

We can also use the WHERE clause with the COUNT(*) function as follows:

mysql> Select COUNT(*) from Student where Address = 'Delhi';

+----------+
| COUNT(*) |
+----------+
| 2        |
+----------+

1 row in set (0.00 sec)
Copy after login

The above is the detailed content of How can we count the number of rows in a table using MySQL SELECT statement?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!