当前位置:网站首页>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
边栏推荐
- Google Earth Engine ——ee.List.sequence函数的使用
- Qt 同时生成动态库和静态库
- LeetCode·23.合并K个升序链表·递归·迭代
- TransGAN代码复现—九天毕昇平台
- Niu Ke Xiaobaiyue Race 53 A-E
- Solve the problem of centos8 MySQL password ERROR 1820 (HY000) You must reset your password using the ALTER USER
- go语言慢速入门——流程控制语句
- socket: Kernel initialization and detailed process of creating streams (files)
- JSESSIONID description in cookie
- MYSQL JDBC图书管理系统
猜你喜欢
GPGGA NTRIP RTCM 笔记
Markdown的使用
牛客小白月赛53 A-E
LeetCode·23.合并K个升序链表·递归·迭代
【Network Security Column Directory】--Penguin Column Navigation
微信公众号授权登录后报redirect_uri参数错误的问题
一个网络两种用途!南开&哈工程提出TINet,通过细化纹理和边缘,在显著性目标检测和伪装目标检测上实现双SOTA!...
c语言进阶篇:指针(五)
我是如何让公司后台管理系统焕然一新的(上) -性能优化
The reason for not using bs4 is that the name is too long?Crawl lottery lottery information
随机推荐
新书上市 |《谁在掷骰子?》在“不确定性时代”中确定前行
LeetCode·23.合并K个升序链表·递归·迭代
Be careful with your dictionaries and boilerplate code
登堂入室之soc开发makefile
【Nacos】解决Nacos下载速度缓慢的问题
MySQL Soul 16 Questions, How Many Questions Can You Last?
面试难题:分布式 Session 实现难点,这篇就够!
Navigation Bar----Personal Center Dropdown
Markdown的使用
基于ABP实现DDD--实体创建和更新
MySQL 有这一篇就够(呕心狂敲37k字,只为博君一点赞!!!)
JDBC (detailed explanation)
手动从0搭建ABP框架-ABP官方完整解决方案和手动搭建简化解决方案实践
DPW-SDNet: Dual Pixel-Wavelet Domain Deep CNNsfor Soft Decoding of JPEG-Compressed Images
navicat连接MySQL报错:1045 - Access denied for user ‘root‘@‘localhost‘ (using password YES)
Deep Non-Local Kalman Network for VideoCompression Artifact Reduction
Generate OOM records in a production environment. Conclusion: Don't be lazy to query useless fields unless you are completely sure.
类和对象——上
这本记述40年前历史的游戏书,预言的却是当下的事
对List集合中每个对象元素按时间顺序排序