乌青膏:如何在SQL中用一个语句实现重复记录的删除

来源:百度文库 编辑:神马品牌网 时间:2024/05/07 05:14:00
如何在SQL中用一个语句实现重复记录的删除

不行吧 可以使用转换来实现
select distinct * into tableb from tablea
drop table tablea
select * into tablea from tableb
drop table tableb
其中tablea是原表
tableb是转换用的表

出现完全一样的记录说明你的数据库很不合理,设置个主键吧

delete from table where id in(select id from table as a,tabel as b where a.id=b.id……)
可能你的表建的不合理,每个表都有必要建个主键的。

delete from TABLE where FIELD in (select FIELD from TABLE group by FIELD having count(FIELD)>1)