如何删除重复的记录 delete from table where id in ( select id from ( select id,count(id) as dup_count from talbe group by id) where dup_count>1 ) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 delete from tmpwhere id in ( select id from ( select id,count(id) as dup_count from tmp group by id) a where a.dup_count>1 ) delete table1from table1 a,(select id from table1 group by id having count(id)>1) bwhere a.id=b.id select distinct * into #tmp from yourtable truncate table yourtableinsert yourtable select * from #tmp chumpg和lmcglmc你们把所有相同记录都delete了,sky_blue做法是保留了一项 delete from tablewhere id not in (select id from table) 修正:delete from tablewhere id not in (select max(id) from table group by id) 参阅《程序员》杂志 2002年11月: 《一道褒贬不一的 SQL 考试题》一文,大概是第一题: 查询重复的sa 关于inserted表取数据的问题 求一SQL语句(nvarchar类型的update) 求一个update语句,要最合理且高效(最好写成存储过程) 数据导入性能问题 A表的B字段与C表的B字段进行判断,重复的跳过 再问一个小问题。如何在SQL SERVER中建立自动递增的ID。mysql和 如何计算相同MIC料号和MIC订单号的单价美金 单价人民币 含税不含税单价的平均值 请问如何定时停此和启动 server 可不可以用返回值接收BLOB数据? sql server恢复的存储过程或者sql 语句怎么写? View 如何用程序调用.sql文件来修改数据库的结构?
where id in (
select id from (
select id,count(id) as dup_count from tmp group by id) a
where a.dup_count>1
)
from table1 a,
(select id from table1 group by id having count(id)>1) b
where a.id=b.id
truncate table yourtable
insert yourtable select * from #tmp
where id not in (select id from table)
delete from table
where id not in (select max(id) from table group by id)