删除重复记录
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)
// 数据库有主键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)
相关文章推荐
- mysql 删除表中的重复记录,只保留其中一条
- 用SQL删除重复记录的N种方法
- 如何删除表记录中重复的字段
- Oracle查询重复数据并删除,只保留一条记录
- 几种查找和删除重复记录的方法
- 删除数据库表中重复的记录
- 删除oracle 表中重复数据sql语句、保留rowid最小的一条记录
- 存储优化 - 删除重复记录只保留单条
- sql语句删除重复的记录的方法
- SQL查询及删除重复记录的方法
- 处理表重复记录(查询和删除)
- 删除表中的重复记录
- 删除重复记录的办法
- 删除重复记录
- 【转】SQL删除重复记录,只保留其中一条
- Oracle删除重复记录只保留一条数据的几种方法
- SQL--处理表重复记录(查询和删除) 示例:查询最近一条用户登陆日志
- 删除重复记录的Sql语句
- sql查询重复记录、删除重复记录方法
- SQL重复记录查询 查询多个字段、多表查询、删除重复记录