Mysql常用Sql
删除表中多余的重复记录,重复记录是根据单个字段(wm_classresid)来判断,只留有wm_id最小的记录
DELETE FROM wm_classresources
WHERE wm_classresid IN (SELECT wm_classresid FROM (SELECT wm_classresid FROM wm_classresources GROUP BY wm_classresid HAVING COUNT(wm_classresid) > 1) a)
AND wm_id NOT IN ( SELECT wm_id FROM (SELECT MIN(wm_id) AS wm_id FROM wm_classresources GROUP BY wm_classresid HAVING COUNT(wm_classresid )>1) b)