MySQL – Count Number of Rows
To count total number of rows present in MySQL Table, select the database and run “SELECT COUNT(*) FROM tablename;” SQL query.
Open mysql command line interface and follow these steps.
1. Select the Database
You can select the database using
2. Query to Count number of rows present in MySQL Table
We shall count the total number of rows in
students table of
There are two rows in the table. Without printing all the row data, we can get just the number of rows in the table using
Run the following query to get the total count of rows present in a table.
SELECT COUNT(*) FROM table_name;
The result is COUNT column with number as single row.
Output of the query is just what we need: number of rows present in table.
In this MySQL Tutorial, we have learnt to count total number of rows present in MySQL Table.