delete from table1 a
where (a.q1, a.q2) IN(select q1,q2 from table1 group by q1,q2 having count(*) > 1)
and q3 not in (select min(q3) from table1 group by q1,q2 having count(*)>1)
参考网上的,用于删除字段q1,q2组合重复的记录。
但是一直提示语法错误。
求高人释疑。
where (a.q1, a.q2) IN(select q1,q2 from table1 group by q1,q2 having count(*) > 1)
and q3 not in (select min(q3) from table1 group by q1,q2 having count(*)>1)
参考网上的,用于删除字段q1,q2组合重复的记录。
但是一直提示语法错误。
求高人释疑。
Ver 8.42 Distrib 5.5.9, for Linux on x86_64
delete a from table1 a,(select q1,q2 from table1 group by q1,q2 having count(*) > 1) b,
(select min(q3) mq from table1 group by q1,q2 having count(*)>1) c
where a.q1=b.q1 and a.q2=b.q2 and a.q3=c.mq;
删除多,可以作废了表。重新建一个新表,把有用数据insert 到新表中。这样可能会比你删除要快,但要注意操作的磁盘空间。很容易撑爆。
where b.q1 is null;
create table t_tmp
select * from t
group by c1,c2;
drop table t;
alter table t_tmp rename to t;
然后重新建立索引。
速度也在接受范围内。