当前位置:网站首页>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
边栏推荐
- QUALITY-GATED CONVOLUTIONAL LSTM FOR ENHANCING COMPRESSED VIDEO
- 3分钟带你了解微信小程序开发
- It is enough for MySQL to have this article (disgusting typing 37k words, just for Bojun!!!)
- Deep Kalman Filter Network for Video Compression Artifact Removal
- Motion Tuned Spatio-temporal Quality Assessmentof Natural Videos
- QUALITY-GATED CONVOLUTIONAL LSTM FOR ENHANCING COMPRESSED VIDEO
- JS中获取元素属性的8大方法
- MySQL 灵魂 16 问,你能撑到第几问?
- navicat无法连接mysql超详细处理方法
- Solve the problem of centos8 MySQL password ERROR 1820 (HY000) You must reset your password using the ALTER USER
猜你喜欢

Quick Master QML Chapter 6 Animation

DPW-SDNet: Dual Pixel-Wavelet Domain Deep CNNs for Soft Decoding of JPEG-Compressed Images

MySQL60题作业

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

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

系统结构考点之并行主存

LeetCode·每日一题·952.按公因数计算最大组件大小·并查集

Niu Ke Xiaobaiyue Race 53 A-E

navicat连接MySQL报错:1045 - Access denied for user ‘root‘@‘localhost‘ (using password YES)

Why do so many people who teach themselves software testing give up later...
随机推荐
折叠旧版应用程序
kubernetes
微信公众号授权登录后报redirect_uri参数错误的问题
WinDbg实践--入门篇
不用bs4的原因居然是名字太长?爬取彩票开奖信息
系统结构考点之CRAY-1向量处理机
Solve npm warn config global `--global`, `--local` are deprecated. use `--location=global` instead
openim支持十万超级大群
Google Earth Engine ——
【问题】Mysql Waiting for table metadata lock 解决方案 修改lock_wait_timeout时间
牛客小白月赛53 A-E
openim支持十万超级大群
The reason for not using bs4 is that the name is too long?Crawl lottery lottery information
Quick Master QML Chapter 6 Animation
[Machine Learning] The Beauty of Mathematics Behind Gradient Descent
About the error of SFML Rect.inl file
Navigation Bar----Personal Center Dropdown
Be careful with your dictionaries and boilerplate code
基于ABP实现DDD--领域逻辑和应用逻辑
MySQL user authorization