- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can we use MySQL SELECT statement to count number of rows in a table?
We need to use COUNT(*) function with SELECT clause to count the total number of rows in a table.
Example
mysql> Select COUNT(*) from Student; +----------+ | COUNT(*) | +----------+ | 4 | +----------+ 1 row in set (0.06 sec)
The query above counts the total number of rows of ‘Student’ table.
We can also use WHERE clause with COUNT(*) function as follows:
mysql> Select COUNT(*) from Student where Address = 'Delhi'; +----------+ | COUNT(*) | +----------+ | 2 | +----------+ 1 row in set (0.00 sec)
- Related Articles
- Can we use SELECT NULL statement in a MySQL query?
- How can we use SET statement to assign a SELECT result to a MySQL user variable?
- How can we count a number of unique values in a column in MySQL table?
- Fastest way to count number of rows in MySQL table?
- Count number of rows in each table in MySQL?
- How to get number of rows in a table without using count(*) MySQL query?
- How can we delete multiple rows from a MySQL table?
- How can we delete all rows from a MySQL table?
- How to use NULL in MySQL SELECT statement?
- How can we use a MySQL subquery with INSERT statement?
- How to count number of rows in a table with jQuery?
- How can I use MySQL IF() function within SELECT statement?
- How to use a select statement while updating in MySQL?
- How can we use SIGNAL statement with MySQL triggers?
- How can we use MySQL SELECT without FROM clause?

Advertisements