如表 test1 有多個重復的字段

其中有些數據完全重復是錯誤的數據,我們要把他找出來,然后刪除掉
select * from test1 a where (a.phone,a.name) in (
select phone,name from test1 group by phone,name having count(*)>1 ) and id not in ( select max(id) from test1 group by phone,name having count(*)>1 );
結果

然后就可以用php或其他語言來刪除這些 id 了
或者
把前面的那個select換成
delete
delete from test1 a where (a.phone,a.name) in (
select phone,name from test1 group by phone,name having count(*)>1 ) and id not in ( select max(id) from test1 group by phone,name having count(*)>1 );
