Chinaunix首页 | 论坛 | 博客
  • 博客访问: 397315
  • 博文数量: 162
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1501
  • 用 户 组: 普通用户
  • 注册时间: 2016-10-21 19:45
文章分类
文章存档

2018年(1)

2017年(101)

2016年(60)

分类: Mysql/postgreSQL

2017-05-19 09:41:23

查找数据库中的重复记录(多个字段):
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) |
给主人留下些什么吧!~~