Find duplicates in the same table in MySQL

后端 未结 13 1903
感动是毒
感动是毒 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:22

    select * from table where artist IN (select artist from table group by artist having count(ID)>1) and release_id IN (select release_id from table group by release_id having count(release_id)>1);
    

    Will Fetch:

    ArtistX : 45677
    ArtistX : 45677
    ArtistY : 378798
    ArtistY : 378798
    

提交回复
热议问题