Get the total number of rows present in MySQL table with/without using count function. In employee table we have 7 records.
SELECT * FROM `employee`;
id name salary
------ ------ --------
1 Ramesh 5000
2 Ashish 4000
3 Rahul 6000
4 Vishal 7000
5 Harsh 3000
6 Kamal 1000
7 Kamal 500
SELECT COUNT(*) FROM employee;Result ::
COUNT(*)
----------
7
We can get the database or table information from the INFORMATION_SCHEMA
SELECT TABLE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'employee';Result ::
TABLE_ROWS
------------
7
Related
find the nth highest salary in mysql without limit