MSSQL 删除重复并只保留一条
重复值查找
select field1,field2 from table
group by field1,field2 having COUNT(*)>1
删除重复值,只保留ID最小的那条
delete table
where field1 in (select field1 from VersionProductRelation a
group by field1,field2 having COUNT(*)>1)
and field2 in (select field2 from VersionProductRelation a
group by field1,field2 having COUNT(*)>1)
and ID not in (
select MIN(ID) from table
group by field1,field2 having COUNT(*)>1)
温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/SQL/11924.html
- 上一篇:oracle 表被另一个用户锁住后的解决办法
- 下一篇:动软生成器添加Mysql注释