数据库中sgbh应该是不重复的数据,如果出现重复的,应删除,并保留id最小的数据
记录一下免得忘记
delete from accident
WHERE sgbh in (select sgbh from (select sgbh from accident GROUP BY sgbh HAVING count(1)>1)a)
and id not in (SELECT id from (select min(id) as id from accident GROUP BY sgbh HAVING count(1)>1) b)
更多推荐
mysql根据单一字段去重
发布评论