侧边栏壁纸
博主头像
落叶人生博主等级

走进秋风,寻找秋天的落叶

  • 累计撰写 130562 篇文章
  • 累计创建 28 个标签
  • 累计收到 9 条评论
标签搜索

目 录CONTENT

文章目录

mysql删除重复行的实现方法

2024-05-12 星期日 / 0 评论 / 0 点赞 / 94 阅读 / 1479 字

表relation create table relation( id int primary key auto_increment, userId int not null, fanId int not null );

表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删除重复行的实现方法,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对编程圈网站的支持!

广告 广告

评论区