I have a table with two columns - artist, release_id
What query can I run to show duplicate records?
e.g. my table is
ArtistX : 45677
ArtistY
you can use this query for the same result. it works for me
SELECT firstname, lastname, list.address FROM list
INNER JOIN (SELECT address FROM list
GROUP BY address HAVING count(id) > 1) dup ON list.address = dup.address
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;
SELECT artist, count(*)
FROM tableName
GROUP BY artist
HAVING count(*) > 1;
SELECT id,artist,COUNT(id) as found FROM table GROUP by id HAVING found > 1
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.
Try this:
SELECT A.ARTIST,A.RELEASE_ID FROM ARTISTS A
WHERE EXISTS(
SELECT 'X' FROM ARTISTS B
WHERE B.ARTIST = A.ARTIST AND B.RELEASE_ID = A.RELEASE_ID
GROUP BY B.ARTIST,B.RELEASE_ID
HAVING COUNT(B.ARTIST)>1)
ORDER BY A.ARTIST;