How to get total number of rows in MySQL table with and without count


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

Get the total number of records with count function

 SELECT COUNT(*) FROM employee;
Result ::
COUNT(*)  
----------
         7

Get the total number of records without count function

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
How to find greater than average salary records in MySQL
how to find duplicate records in MySQL query
How to use second index forcefully in MySQL
Difference between where and having clauses