How to get total number of records of table in mysql


We can get the total number of records of table in mysql by using count() function

By using Count

SELECT COUNT(*) FROM test;

Total records by status

SELECT 
  COUNT(IF(status = 'Cancelled', 1, NULL)) 'Cancelled',
  COUNT(IF(status = 'On Hold', 1, NULL)) 'On Hold',
  COUNT(IF(status = 'Confirm', 1, NULL)) 'Confirm',
  COUNT(IF(status = 'Disputed', 1, NULL)) 'Disputed' 
FROM
  orders ;

Total records without using count

SELECT 
  TABLE_ROWS 
from
  INFORMATION_SCHEMA.TABLES 
WHERE TABLE_NAME = 'employee' ;


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
How to get total number of rows in MySQL table with and without count