查找数据库中的重复记录(多个字段):
SELECT * FROM wcs_best_fitness_individual WHERE (spokeCounts,isSpokeClosure,deflectionAngleOne,deflectionAngleTwo) IN
(SELECT spokeCounts,isSpokeClosure,deflectionAngleOne,deflectionAngleTwo FROM wcs_best_fitness_individual
GROUP BY spokeCounts,isSpokeClosure,deflectionAngleOne,deflectionAngleTwo HAVING COUNT(*) >1);
查找数据库中多余的重复记录(多个字段,已保留一条数据):
SELECT * FROM wcs_best_fitness_individual WHERE (spokeCounts,isSpokeClosure,deflectionAngleOne,deflectionAngleTwo) IN
(SELECT spokeCounts,isSpokeClosure,deflectionAngleOne,deflectionAngleTwo FROM wcs_best_fitness_individual
GROUP BY spokeCounts,isSpokeClosure,deflectionAngleOne,deflectionAngleTwo HAVING COUNT(*) >1) AND
id NOT IN (SELECT id FROM wcs_best_fitness_individual GROUP BY
spokeCounts,isSpokeClosure,deflectionAngleOne,deflectionAngleTwo HAVING COUNT(*)>1);
阅读(842) | 评论(0) | 转发(0) |