删除重复项目 保留id最小的数据
2021-03-10 本文已影响0人
阳光也学会了妩媚
DELETE FROM jc_company where name IN ( SELECT t.name FROM ( SELECT name FROM jc_company GROUP BY name HAVING count(1) > 1 ) t )AND id NOT IN (SELECT dt.mindeptno FROM ( SELECT min(id) AS mindeptno FROM jc_company GROUP BY name HAVING count(1) > 1 ) dt)
表名 company
重复列 name
索引 id