Find duplicates in the same table in MySQL

SELECT
    artist, release_id, count(*) no_of_records, group_concat(id)
FROM table
GROUP BY artist, release_id
HAVING count(*) > 1;

also adding group_concat(id) gets you all ids of the duplicates.


SELECT id,artist,COUNT(*) FROM myTable
GROUP BY artist, release_id HAVING COUNT(*) > 1

You can use a grouping across the columns of interest to work out if there are duplicates.

SELECT
    artist, release_id, count(*) no_of_records
FROM table
GROUP BY artist, release_id
HAVING count(*) > 1;

Tags:

Mysql