星星博客 »  > 

2021-06-01

SQL删除数据库某一字段内容重复的数据行
删除[field]字段内容重复的数据,[table]表名,[field]字段名

DELETE FROM [table] WHERE [id] NOT IN(SELECT MIN([id]) FROM
(SELECT MIN([id]) FROM [B_SensitiveWord] GROUP BY [field] Having Count()>1
UNION SELECT MIN([id]) FROM [table] GROUP BY [field] Having Count(
)=1)a)
保留[id]最小的数据,删除其他重复的数据

备注:[id]字段为int类型,可计算

来自:https://www.cnblogs.com/yuejin/p/13377056.html

相关文章