In MySQL find the Find the duplicate records by using COUNT function
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 `name`,COUNT(*) AS total FROM `employee` GROUP BY `name` HAVING COUNT(`name`)>1; # OR SELECT `name`,count(*) as total FROM `employee` GROUP BY `name` having total>1;
Output ::
name total ------ -------- Kamal 2
SELECT ColumnA, ColumnB, ColumnC, count(*) as total from table group by ColumnA, ColumnB, ColumnC having total > 1;
Related
find the nth highest salary in mysql without limit