当前位置:网站首页>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
边栏推荐
- 折叠旧版应用程序
- Deep Kalman Filter Network for Video Compression Artifact Removal
- Simple configuration of three-tier architecture
- 你需要知道的ES6—ES13开发技巧
- Navigation Bar----Personal Center Dropdown
- DistSQL in-depth analysis: creating a dynamic distributed database
- About the error of SFML Rect.inl file
- ArrayList扩容机制分析
- ML.NET相关资源整理
- The reason for not using bs4 is that the name is too long?Crawl lottery lottery information
猜你喜欢

面试难题:分布式 Session 实现难点,这篇就够!

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

外包干了三年,废了...

新书上市 |《谁在掷骰子?》在“不确定性时代”中确定前行

类和对象——上

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

openim支持十万超级大群

ClickHouse删除数据之delete问题详解
![[Deep Learning] Target Detection | SSD Principle and Implementation](/img/07/ea4ff3ffbe7e0c11ff7baec0e1818f.jpg)
[Deep Learning] Target Detection | SSD Principle and Implementation

Solve the problem of centos8 MySQL password ERROR 1820 (HY000) You must reset your password using the ALTER USER
随机推荐
走进Redis,让你重新认识redis。绝不是表面
活动推荐 | 2022年深圳最值得参加的边缘计算活动
导航栏----个人中心 Dropdown
MySQL cursors
不用bs4的原因居然是名字太长?爬取彩票开奖信息
[Machine Learning] The Beauty of Mathematics Behind Gradient Descent
面试难题:分布式 Session 实现难点,这篇就够!
WinDbg实践--入门篇
【Nacos】解决Nacos下载速度缓慢的问题
牛客网——业务分析-提取值
这本记述40年前历史的游戏书,预言的却是当下的事
【信息安全技术】RSA算法的研究及不同优化策略的比较
NEOVIM下载安装与配置
手动从0搭建ABP框架-ABP官方完整解决方案和手动搭建简化解决方案实践
Deep Non-Local Kalman Network for VideoCompression Artifact Reduction
mpls简介
Niu Ke Xiaobaiyue Race 53 A-E
基于ABP实现DDD--实体创建和更新
mysql创建表
ClickHouse 创建数据库建表视图字典 SQL