mysql刪除重復行的實現方法
發(fā)布日期:2022-03-22 14:56 | 文章來源:源碼之家
表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刪除重復行的實現方法,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對本站網站的支持!
版權聲明:本站文章來源標注為YINGSOO的內容版權均為本站所有,歡迎引用、轉載,請保持原文完整并注明來源及原文鏈接。禁止復制或仿造本網站,禁止在非www.sddonglingsh.com所屬的服務器上建立鏡像,否則將依法追究法律責任。本站部分內容來源于網友推薦、互聯(lián)網收集整理而來,僅供學習參考,不代表本站立場,如有內容涉嫌侵權,請聯(lián)系alex-e#qq.com處理。
相關文章