mysql删除重复行的实现方法
16lz
2021-12-26
表relation
create table relation( id int primary key auto_increment, userId int not null, fanId int not null );
insert into relation(userId,fanId) values(1,1) ,(1,1) ,(1,1), (2,2),(2,2) ,(3,3),(3,3);
id | userId | fanId |
---|---|---|
1 | 1 | 1 |
2 | 1 | 1 |
3 | 1 | 1 |
4 | 2 | 2 |
5 | 2 | 2 |
6 | 3 | 3 |
7 | 3 | 3 |
去重
delete t from relation sjoin relation t using(userId,fanId)where s.id<t.id;
更多相关文章
- MySQL系列多表连接查询92及99语法示例详解教程
- Linux下MYSQL 5.7 找回root密码的问题(亲测可用)
- MySQL 什么时候使用INNER JOIN 或 LEFT JOIN
- ES6 变量声明,箭头函数,数组方法,解构赋值,JSON,类与继承,模块化练习
- 浅谈Java中Collections.sort对List排序的两种方法
- Python list sort方法的具体使用
- python list.sort()根据多个关键字排序的方法实现
- android上一些方法的区别和用法的注意事项
- android实现字体闪烁动画的方法