您的位置:首页 > 数据库

关于对数据库中重复记录的操作

2010-09-25 14:20 211 查看
1、如何查询重复的记录,并取出指定的记录?

select * from Table1 t1 where id in (select max(id) from Table1 t2 where t1.id=t2.id)

2、如何删除记录中重复的数据?

delete from Table1 where id not in (select id from Table1 t1 where id in (select max(id) from Table1 t2 where t1.id=t2.id))
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: