access 数据库查看重复记录,删除重复记录select语句

180it 2019-10-23 PM 3875℃ 0条

//查看所有保留最大ID
select * from [表名] where [字段ID] not in(select min([字段ID]) from [表名] group by [去重的字段])

//查看所有保留最小ID
select * from [表名] where [字段ID] not in(select max([字段ID]) from [表名] group by [去重的字段])

//统计每一个重复记录条数
//SELECT [去重的字段],Count() FROM [[表名]] GROUP BY [[去重的字段]] HAVING Count()>1;

//所有重复记录保留最小ID
delete from [表名] where [字段ID] not in(select min([字段ID]) from [表名] group by [去重的字段])

//所有重复记录保留最大ID
delete from [表名] where [字段ID] not in(select max([字段ID]) from [表名] group by [去重的字段])

支付宝打赏支付宝打赏 微信打赏微信打赏

如果文章或资源对您有帮助,欢迎打赏作者。一路走来,感谢有您!

标签: none

access 数据库查看重复记录,删除重复记录select语句