怎么在mysql中删除重复行
发布时间:2022-02-15 14:22:55 所属栏目:MySql教程 来源:互联网
导读:今天就跟大家聊聊有关怎么在mysql中删除重复行,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。 表relation create table relation( id int primary key auto_increment, userId int not null,
今天就跟大家聊聊有关怎么在mysql中删除重复行,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。 表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中删除重复行有进一步的了解吗? (编辑:永州站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
站长推荐