欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

mysql刪除重復(fù)行的實現(xiàn)方法

 更新時間:2018年06月29日 11:17:18   作者:勇敢的飛石  
這篇文章主要介紹了mysql刪除重復(fù)行的實現(xiàn)方法,非常不錯,具有一定的參考借鑒價值,需要的朋友可以參考下

表relation

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

插入幾條數(shù)據(jù)

insert into relation(userId,fanId) 
values(1,1) ,(1,1) ,(1,1), (2,2),(2,2) ,(3,3),(3,3);

表中的數(shù)據(jù)

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;

總結(jié)

以上所述是小編給大家介紹的mysql刪除重復(fù)行的實現(xiàn)方法,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評論