DELETE FROM model_areacounty WHERE (province_id,title) IN (SELECT province_id,title FROM (SELECT province_id,title FROM model_areacounty GROUP BY province_id,title HAVING COUNT(*)>1) s1) AND id NOT IN (SELECT id FROM (SELECT id FROM model_areacounty GROUP BY province_id,title HAVING COUNT(*)>1) s2);