当前位置:网站首页>mysql remove duplicate data
mysql remove duplicate data
2022-07-30 21:36:00 【bhegi_seg】
mysql remove duplicate data
Query duplicate data according to one column (judging duplicate data according to single column)
SELECT * FROM tab_test
WHERE ONE IN (SELECT ONE FROM testdelete GROUP BY ONE HAVING COUNT(ONE) >1)
Delete duplicate records in the table: (delete according to a single column and keep the one with the smallest ID)
DELETE
FROM tab_test
WHERE ONE IN(SELECT
ONE
FROM (SELECT
ONE
FROM tab_test
GROUP BY ONE
HAVING COUNT(ONE) > 1) a)
AND id NOT IN(SELECT
*
FROM (SELECT
MIN(id)
FROM tab_test
GROUP BY ONE
HAVING COUNT(ONE) > 1) b);
Judging repetition according to one,two,three: (Judging repetition according to single and multiple)
SELECT * FROM tab_test a
WHERE (a.one,a.two,a.three) IN
(SELECTONE,two,three FROM tab_test GROUP BY ONE,two,three HAVING COUNT(*) > 1) ;
Delete duplicate data in the table (delete according to multiple columns and keep the one with the smallest ID)
DELETE
FROM tab_test
WHERE (ONE,two,three)IN(SELECT
ONE,
two,
three
FROM (SELECT
ONE,
two,
three
FROM tab_test
GROUP BY ONE,two,three
HAVING COUNT(* ) > 1) a)
AND id NOT IN(SELECT
MIN(id)
FROM (SELECT
MIN(id) AS id
FROM tab_test
GROUP BY ONE,two,three
HAVING COUNT( * ) > 1) b)
Find redundant duplicate records (multiple fields) in the table, excluding the record with the smallest id (check duplicates based on multiple fields but not include the smallest id)
SELECT *
FROM tab_test a
WHERE(a.one,a.two,a.three)IN(SELECT
ONE,
two,
three
FROM tab_test
GROUP BY ONE,two,three
HAVING COUNT( * ) > 1)
AND id NOT IN(SELECT
MIN(id) AS id
FROM tab_test
GROUP BY ONE,two,three
HAVING COUNT( * ) > 1);
Let me introduce myself first. The editor graduated from Shanghai Jiaotong University in 2013. I worked in a small company and went to big factories such as Huawei and OPPO. I joined Alibaba in 2018, until now.I know that most junior and intermediate java engineers want to upgrade their skills, they often need to explore their own growth or sign up to study, but for training institutions, the tuition fee is nearly 10,000 yuan, which is really stressful.Self-learning that is not systematic is very inefficient and lengthy, and it is easy to hit the ceiling and the technology stops.Therefore, I collected a "full set of learning materials for java development" for everyone. The original intention is also very simple. I hope to help friends who want to learn by themselves but don't know where to start, and at the same time reduce everyone's burden.Add the business card below to get a full set of learning materials
边栏推荐
- Teach you how to build a permanently running personal server
- Outsourcing worked for three years, it was abolished...
- [Limited Time Bonus] 21-Day Learning Challenge - MySQL from entry to mastery
- 登堂入室之soc开发makefile
- bgp路由过滤
- Generate OOM records in a production environment. Conclusion: Don't be lazy to query useless fields unless you are completely sure.
- 共用体、共用体与结构体的区别、枚举之C语言犄角旮旯的知识
- DPW-SDNet: Dual Pixel-Wavelet Domain Deep CNNs for Soft Decoding of JPEG-Compressed Images
- mysql死锁
- 解决centos8 MySQL密码问题ERROR 1820 (HY000) You must reset your password using ALTER USER
猜你喜欢
![[Deep Learning] Understanding of Domain Adaptation in Transfer Learning and Introduction of 3 Techniques](/img/51/b351385c1f0f4e0a545e54c8ae7491.png)
[Deep Learning] Understanding of Domain Adaptation in Transfer Learning and Introduction of 3 Techniques

Markdown的使用

解决centos8 MySQL密码问题ERROR 1820 (HY000) You must reset your password using ALTER USER

Advanced c language: pointers (5)

kubernetes

我是如何让公司后台管理系统焕然一新的(上) -性能优化

系统结构考点之并行主存

IDEA2018.3.5 cancel double-click Shift shortcut

Automatically generate test modules using JUnit4 and JUnitGenerator V2.0 in IDEA

MySQL 游标
随机推荐
登堂入室之soc开发makefile
1064 Complete Binary Search Tree
Google Earth Engine ——
socket:内核初始化及创建流(文件)详细过程
MySQL60题作业
Image Restoration by Estimating Frequency Distribution of Local Patches
基于ABP实现DDD--仓储实践
HCIP第十六天
CISP-PTE真题演示
手把手教你搭建一台永久运行的个人服务器
三层架构简单配置
基于ABP实现DDD--领域服务、应用服务和DTO实践
It is enough for MySQL to have this article (disgusting typing 37k words, just for Bojun!!!)
navicat新建数据库
对List集合中每个对象元素按时间顺序排序
微信公众号授权登录后报redirect_uri参数错误的问题
Niu Ke Xiaobaiyue Race 53 A-E
ELF:加载过程
3分钟带你了解微信小程序开发
Google Earth Engine ——ee.List.sequence函数的使用