1、查找表中多余的重复记录(根据单个字段studentid)
 
select * from table_name where studentid in (select studentid from table_name group by studentid having count(studentid) > 1)
 
2、查找表中多余的重复记录(根据多个字段studentid,name...)
 
select * from table_name a where (a.studentid,a.name) in(select studentid,name from 表 group by studentid,name having count(*) > 1)
 
3、删除表中多余的重复记录(根据单个字段studentid)
 
delete from table_name a where a.studentid in( select studentid from table_name group by studentid having count(studentid) > 1)
 
4、删除表中多余的重复记录(根据多个字段studentid,name...)
 
delete from table_name a where (a.studentid,a.name) in( select studentid,name from table_name group by studentid,name having count(*) > 1)
 
5、删除表中多余的重复记录(根据单个字段studentid),只保留id最小的记录
 
delete from table_name a where a.name in( select name from table_name group by id having count(name) > 1)
and a.id not in (select min(id) from table_name group by name having count(*) > 1)
 
6、删除表中多余的重复记录(根据多个字段name,studentid...),只保留id最小的记录
 
delete from table_name a where (a.name,a.studentid) in (select name,studentid from table_name group by name,studentid having count(*) > 1)
and a.id not in (select min(id) from table_name group by name,studentid having count(*)>1)

最新文章

  1. Mybatis的基本操作案列增加以及源码的分析(二)
  2. EF架构~CodeFirst生产环境的Migrations
  3. AStar算法的学习
  4. Jasper(物联网网络支撑平台公司)的技术为什么这么牛逼?
  5. select()函数 timval问题
  6. 监听器初始化Job、JobTracker相应TaskTracker心跳、调度器分配task源码级分析
  7. GNU Radio 之 rtl-sdr
  8. 搜索 基础 AC 2014-01-14 15:53 170人阅读 评论(0) 收藏
  9. 将数字映射到字母上 .xml
  10. WIN7 下 Qt Creator 安装 QWT
  11. Bigcommerce:intershop编程经验总结
  12. 判断textview是否被截断
  13. canvas绘制自定义的曲线,以椭圆为例,通俗易懂,童叟无欺
  14. linux shell脚本学习xargs命令使用详解
  15. Mockito教程
  16. HDU1284--完全背包
  17. 【转1】Appium 1.6.3 在Xcode 8, iOS 10.2(模拟器)测试环境搭建 经验总结
  18. chattr文件锁
  19. 【新特性】JDK11
  20. 封装个 Android 的高斯模糊组件

热门文章

  1. poj 2385 Apple Catching(dp)
  2. C++中,访问字符串的三种方法
  3. [POJ 3734] Blocks (矩阵高速幂、组合数学)
  4. HDU 1085 Holding Bin-Laden Captive! (母函数)
  5. EffectiveC#5--始终提供ToString()
  6. Android 使用monkey自动测试
  7. Spring mvc中@RequestMapping 6个基本用法整理
  8. poj1623 Squadtrees
  9. Reading source code
  10. Windows I/O模型之一:Select模型