Sql 删除重复行记录
2008-03-03 09:58
162 查看
首先查询具有重复记录的所有记录
select iCityID,name,count(*) as count from testUpdate group by iCityID,name
having count(*)>1
order by count desc
(1) 通过以下语句可以删除掉重复的记录
delete from testUpdate where exists(
select 1 from testUpdate t
where testUpdate.userid>t.userId and testUpdate.name=t.name and testUpdate.iCityID=t.iCityID)
(2)也可以通过这种方式删除重复记录
delete from TestUpdate where userID not in (select max(userid) from TestUpdate group by iCityID,name)
删除记录要小心操作,最好做个备份。
select iCityID,name,count(*) as count from testUpdate group by iCityID,name
having count(*)>1
order by count desc
(1) 通过以下语句可以删除掉重复的记录
delete from testUpdate where exists(
select 1 from testUpdate t
where testUpdate.userid>t.userId and testUpdate.name=t.name and testUpdate.iCityID=t.iCityID)
(2)也可以通过这种方式删除重复记录
delete from TestUpdate where userID not in (select max(userid) from TestUpdate group by iCityID,name)
删除记录要小心操作,最好做个备份。
相关文章推荐
- 用SQL语句删除重复记录
- Sql server 删除重复记录的SQL语句
- SQL删除表中有重复的记录
- 删除Table中完全重复记录 SQL语句
- 在SQL中删除重复记录的多种方法
- SQL--处理表重复记录(查询和删除) 示例:查询最近一条用户登陆日志
- 用SQL删除重复记录的N种方法
- 几个删除重复记录的SQL语句
- SQL删除重复记录的方法
- 【Transact-SQL】一句SQL删除重复记录
- 【转】SQL删除某些字段重复的记录(只保留一条)
- SQL 删除重复记录
- 几个删除重复记录的SQL语句
- 在SQL中删除重复记录(多种方法)(转)
- 在SQL中删除重复记录(多种方法)
- SQL删除重复记录的N种方法
- 使用一条SQL语句删除表中重复记录
- SQL对冗余数据的删除重复记录只保留单条的说明
- Oracle 查询并删除重复记录的SQL语句
- SQL怎么查询重复记录,删除重复记录