标签:class div mys 最小 sql查询 HERE 保留 pre having
1.查询重复值:
select code,count(*) as count from hospital group by code having count>1;
该语句查询code重复值大于1的记录
2.删除重复:
DELETE FROM hospital WHERE id NOT IN (SELECT dt.minno FROM (SELECT MIN(id) AS minno FROM hospital GROUP BY code) dt);
该语句保留id最小的记录,其余code重复的记录全部删除
标签:class div mys 最小 sql查询 HERE 保留 pre having
原文地址:https://www.cnblogs.com/xienb/p/11328239.html