How to get total number of rows in MySQL table using ...

Count number of rows present in MySQL table using SELECT COUNT(*)

To count total number of rows present in MySQL Table, select the database and run "SELECT COUNT(*) FROM tablename;" SQL query.

Count number of rows in MySQL Table

Open mysql command line interface and follow these steps.

Select the Database

You can select the database using USE database; .

Query to Count number of rows present in MySQL Table

We shall count the total number of rows in students table of school database.

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 COUNT keyword. Run the following query to get the total count of rows present in a table.

mysql> SELECT COUNT(*) FROM tablename;

mysql> SELECT COUNT(*) FROM tablename;

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.

Conclusion

In this MySQL Tutorial, we have learnt to count total number of rows present in MySQL Table.

Learn MySQL

MySQL Tutorial

User Management

MySQL Server - Login to mysql Command Line Interface MySQL Server - Get list of All Users MySQL Server - Get list of Connected Users

DATABASE

MySQL - Create DATABASE MySQL - Delete DATABASE MySQL - Show existing Databases MySQL - Select or Use DATABASE

TABLE

MySQL - Create Table MySQL - Rename Table MySQL - Duplicate a Table MySQL - Add a new Column to Table MySQL - Delete or Drop a Column from MySQL Table MySQL - Select Distinct Values of Column MySQL - Count number of rows in Table MySQL - Increase column size MySQL - Add an AUTO_INCREMENT column as PRIMARY KEY MySQL - Add Column to INDEX MySQL - Delete or Drop Column from INDEX MySQL - SHOW INDEX of Table MySQL - Rename Column or Change Column

Solve Issues

MySQL - LAST_INSERT_ID returns 0

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download