今天就跟大家聊聊有关怎么在mysql中删除重复行,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。

表relation

createtablerelation(idintprimarykeyauto_increment,userIdintnotnull,fanIdintnotnull);

插入几条数据

insertintorelation(userId,fanId)values(1,1),(1,1),(1,1),(2,2),(2,2),(3,3),(3,3);

表中的数据

iduserIdfanId111211311422522633733

去重

deletetfromrelationsjoinrelationtusing(userId,fanId)wheres.id<t.id;

看完上述内容,你们对怎么在mysql中删除重复行有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注亿速云行业资讯频道,感谢大家的支持。