Get list of duplicate rows in MySql

前端 未结 4 794
忘了有多久
忘了有多久 2021-02-04 19:01

i have a table like this

ID     nachname     vorname
1       john         doe
2       john         doe
3       jim          doe
4       Michael     Knight
         


        
4条回答
  •  梦毁少年i
    2021-02-04 19:47

    The following query will give the list of duplicates :

    SELECT n1.* FROM table n1
    inner join table n2 on n2.vorname=n1.vorname and n2.nachname=n1.nachname
    where n1.id <> n2.id
    

    BTW The data you posted seems to be wrong "Doe" and "Knight" are a lastname, not a firstname :p.

提交回复
热议问题