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重复的记录全部删除
原文地址:https://www.cnblogs.com/xienb/p/11328239.html
时间: 2024-10-09 20:56:39