数据库删除重复数据
删除重复数据,以下sql语句多次循环执行,直到没有可删除的数据,就可以达到想要的效果
DELETE FROM project_camera_lens WHERE id IN ( SELECT a.id FROM ( SELECT min( id ) id, min( lens_number ), lens_number, COUNT( 1 ) cnt FROM project_camera_lens GROUP BY lens_number HAVING cnt > 1 ORDER BY cnt DESC ) AS a )
资产数据删除
DELETE FROM project_assets WHERE id IN ( SELECT a.id FROM ( SELECT min( id ) id, min( eng_name ), eng_name, COUNT( 1 ) cnt FROM project_assets GROUP BY eng_name HAVING cnt > 1 ORDER BY cnt DESC ) AS a )