您的位置:首页 > 其它

删除重复记录

2011-07-22 12:23 169 查看
面试的时候经常会有删除数据库重复记录的sql
// 数据库有主键id,查找col相同的记录
delete from table t where t.id not in (select min(tb.id) from table tb where tb.col=t.col)
// 数据库中没有主键id,查找col 相同的记录
delete from table t where t.rowid not in (select min(tb.rowid) from table tb where tb.col=t.col)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: