标签:重复数据 int ODB nod innodb utf8 group count mys
表结构如下,需要增加xx,yy复合唯一索引。id
)保留最小id
delete a.* from table_a as a,( select min(id) id , xx,yy from table_a group by xx,yy having count(1)>1
) as b where a.yy=b.yy and a.xx=b.xx and a.id > b.id;
保留最大id
delete a.* from table_a as a,( select max(id) id , xx,yy from table_a group by xx,yy having count(1)>1
) as b where a.yy=b.yy and a.xx=b.xx and a.id < b.id;
标签:重复数据 int ODB nod innodb utf8 group count mys
原文地址:https://blog.51cto.com/liuminkun/2370360