有一张表 A 字段名是id,mobile,flag,sendtime 怎么删除这张表中重复的数据最快。
delete A where id not in
(
select min(b.id) from A as b where A.mobile=b.mobile
)
除了这种的 还有没有比这种的更快的 效率更高的 !!!
前提条件 这张表中数据量超过1亿
select distinct * into #Temp from A
drop table a
select * into a from #Temp
Delete from tablename where id not in (select max(id) from tablename group by col1,col2,...)
delete from tbalename group by mobie having count(*)>2 要确定mobie是唯一的主键
先筛选出来重复的数据,然后再用你的语句就可以提高很多