表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 s
join relation t using(userId,fanId)
where s.id<t.id;

总结

以上所述是小编给大家介绍的mysql删除重复行的实现方法,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!

标签:
mysql删除重复行,mysql,删除重复

免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
狼山资源网 Copyright www.pvsay.com

评论“mysql删除重复行的实现方法”

暂无“mysql删除重复行的实现方法”评论...