Count duplicates records in Mysql table?

The approach is to have a nested query that has one line per duplicate, and an outer query returning just the count of the results of the inner query.

SELECT count(*) AS duplicate_count
FROM (
 SELECT name FROM tbl
 GROUP BY name HAVING COUNT(name) > 1
) AS t

Leave a Comment