当前位置:网站首页>mysql delete duplicate data in the table, (retain only one row)
mysql delete duplicate data in the table, (retain only one row)
2022-07-30 06:47:00 【that's the name】
The data in the example table is as follows:
According to uniqle_idThis column is used to determine whether the data is repeated
1. Check the repeated data
select uniqle_id,name from person group by uniqle_id having count(span>uniqle_id) > 1The result is as follows:
2. Remove duplicatesColumn, only keep the row with the smallest id
delete from person where uniqle_id in (select * from(select min(uniqle_id) from person group by uniqle_idhaving count(uniqle_id) > 1) temp)and id not in(select * from(select min(id) from person group by uniqle_idhaving count(uniqle_id)> 1 )temp2)3. Delete all duplicate lines
delete from person where uniqle_id in (select * from(select min(uniqle_id)as uniqle_id from person groupby uniqle_id having count(uniqle_id) > 1) temp)(The purpose of temp in sql is to give the result of the sub-query an alias. If this alias is not available, an error will be reported: SQL error [1248] [42000]: Every derived table must have its own alias)
边栏推荐
- Competition WP in May
- Understand JDBC in one article
- Jackson serialization failure problem - oracle data return type can't find the corresponding Serializer
- MySQL 5.7 安装教程(全步骤、保姆级教程)
- Operators and Interaction Basics
- C#利用开源NPlot实现K线图(蜡烛图)
- sql中 exists的用法
- misc-log analysis of CTF
- misc-file steganography of CTF
- 学生管理系统
猜你喜欢
![[Net Ding Cup 2020 Qinglong Group] AreUSerialz](/img/f2/9aef8b8317eff31af2979b3a45b54c.png)
[Net Ding Cup 2020 Qinglong Group] AreUSerialz

Monstache执行Monstache - f配置。toml出错不存在处理器类型和名称(附件)(= parse_exc类型

JDBC programming of MySQL database
CTF之misc-其他类型隐写

互联网商城盲盒app为何如此火爆
CTF之misc-内存分析(Volatility)
![[HCTF 2018]admin](/img/4e/58234ca163c22fc334334eb89a5b00.png)
[HCTF 2018]admin

oracle row to column, column to row summary

Flink CDC 实现Postgres到MySQL流式加工传输案例
Misc-traffic analysis of CTF
随机推荐
[MATLAB]图像处理——交通标志的识别
[Net Ding Cup 2020 Qinglong Group] AreUSerialz
FastAPI Quick Start
[Mini Program Project Development--Jingdong Mall] Classification Navigation Area of uni-app
sqli-labs less3/4 Targeting Notes
【面经】米哈游数据开发面经
misc-file steganography of CTF
npm run serve starts error npm ERR Missing script "serve"
phpok website vulnerability exploitation analysis
Servlet basic principles and application of common API methods
oracle row to column, column to row summary
批量自动归集
Operators and Interaction Basics
Online sql editing query tool sql-editor
TDengineGUI无法连接TDengine
mysql删除表中重复数据,(只保留一行)
Offensive and defensive world easy_web
Remember a Mailpress plugin RCE vulnerability recurrence
uni-app使用npm命令安装组件
学生管理系统