好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

使用SQL语句去掉重复的记录【两种方法】

海量数据(百万以上),其中有些全部字段都相同,有些部分字段相同,怎样高效去除重复?

如果要删除手机(mobilePhone),电话(officePhone),邮件(email)同时都相同的数据,以前一直使用这条语句进行去重:

delete from 表 where id not in  
(select max(id) from 表 group by mobilePhone,officePhone,email )  
or 
delete from 表 where id not in  
 (select min(id) from 表 group by mobilePhone,officePhone,email ) 

delete from 表 where id not in 
(select max(id) from 表 group by mobilePhone,officePhone,email ) 
or 
delete from 表 where id not in 
 (select min(id) from 表 group by mobilePhone,officePhone,email )  

查看更多关于使用SQL语句去掉重复的记录【两种方法】的详细内容...

  阅读:48次