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)站的支持!
您可能感興趣的文章:
- mysql刪除重復(fù)記錄語句的方法
- MySQL中查詢、刪除重復(fù)記錄的方法大全
- mysql查找刪除重復(fù)數(shù)據(jù)并只保留一條實例詳解
- MySQL數(shù)據(jù)庫中刪除重復(fù)記錄的方法總結(jié)[推薦]
- mysql刪除表中某一字段重復(fù)的記錄
- mysql查找刪除表中重復(fù)數(shù)據(jù)方法總結(jié)
- 刪除MySQL重復(fù)數(shù)據(jù)的方法
- MySQL中刪除重復(fù)數(shù)據(jù)的簡單方法
- 刪除mysql數(shù)據(jù)庫中的重復(fù)數(shù)據(jù)記錄
- Mysql刪除重復(fù)數(shù)據(jù)通用SQL的兩種方法
相關(guān)文章
Mysql之EXPLAIN顯示using filesort介紹
EXPLAIN 是mysql解釋select查詢的一個關(guān)鍵字,可以很方便的用于調(diào)試2012-02-02

