We need to use the COUNT(*) function and the SELECT clause to count the total number of rows in the table.
mysql> Select COUNT(*) from Student; +----------+ | COUNT(*) | +----------+ | 4 | +----------+ 1 row in set (0.06 sec)
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)
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!