软件下载吧文章资讯

分类分类

SQL开发知识:不同方法实现SQL语句去掉重复的记录

2024-02-28 13:28作者:下载吧

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

如果要删除手机(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 )

展开全部

相关文章

说两句网友评论
    我要跟贴
    取消