如果数据量不是很大的话 delete from tt a where exists (select 1 from tt where id=a.id and name=a.na me and value=a.value rowid>a.rowid);上面where条件根据你对重复的定义相应修改,重复数据会保留一行,其余的删除
一般都这样:在所看到的记录都相同的情况下,每条记录的rowid都不一样的。这样先对相同的记录进行分组筛选出,然后删除就可以了。 对于你的例子: delete from tt where id in(select id from (select rowid,id from t) group id having count(*)>1)
delete from tt a where exists (select 1 from tt where id=a.id and name=a.na
me and value=a.value rowid>a.rowid);上面where条件根据你对重复的定义相应修改,重复数据会保留一行,其余的删除
对于你的例子:
delete from tt where id in(select id from (select rowid,id from t) group id having count(*)>1)
http://temp.5tzone.com/html/computer/database/2006-1/17/200601172303338035302.htm