您的位置:首页 > 数据库

查询,删除重复数据 sql.TXT

2012-02-27 16:36 375 查看
-------------查询重复记录

select * from testtable where rowid in
(select a.rowid from testtable a, testtable b where a.rowid>b.rowid and a.a=b.a  )

select * from hz_zhuangbeib where rowid in
(select a.rowid from hz_zhuangbeib a, hz_zhuangbeib b where a.rowid>b.rowid and a.zhuangbeinm=b.zhuangbeinm  )

select * from testtable a where rowid < (select max(b.rowid) from testtable b where a.a=b.a );

---删除大数据量重复的语句 效率较高
delete testtable where rowid not in(select min(rowid) from testtable group by a);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: