发布网友 发布时间:2022-04-23 22:57
共1个回答
热心网友 时间:2022-04-30 11:16
假设表结构为
t1(a,b)
删除a列有重复的记录
delete from t1,(select a from t1 group by a having count(1)>1) t where t1.a=t.a;
如果希望对于有重复的记录只保留其中一条而不是全部删除,则可运行下列语句,前提是数据表必须含有自增id列。语句如下:
delete from t1,(select a,max(id) as id from t1 group by a having count(1)>1) t where t1.a=t.a and t1.id<>t.id;