Find duplicates in the same table in MySQL

后端 未结 13 1935
感动是毒
感动是毒 2020-12-10 02:03

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         


        
13条回答
  •  星月不相逢
    2020-12-10 02:08

    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;
    

提交回复
热议问题