MySql数据库查询某个列的重复值(vc_name:要查询的重复字段,xm_position:要查询的表名)
select vc_name,count(*) as count from xm_position group by vc_name having count>1;
删除所查询出来多于的重复值,最大的ID留下,删除其它所有重复的
DELETE FROM xm_position WHERE id NOT IN (SELECT dt.minno FROM (SELECT MAX(id) AS minno FROM xm_position GROUP BY vc_name) dt);