www.fltk.net > mysql大批量删除重复数据怎么做

mysql大批量删除重复数据怎么做

你只是删掉那些重复值的一个记录,但重复的可能超过2个,所以还会重复。换成这句试试(里面的主键要换成你对应的) delete from lc_lift_info where liftid_code not in (select * from (select min(主键) from lc_lift_info group by liftid_co...

你只是删掉那些重复值的一个记录,但重复的可能超过2个,所以还会重复。换成这句试试(里面的主键要换成你对应的)delete from lc_lift_info where liftid_code not in (select * from (select min(主键) from lc_lift_info group by liftid_code))

例如: id name value 1 a pp 2 a pp 3 b iii 4 b pp 5 b pp 6 c pp 7 c pp 8 c iii id是主键 要求得到这样的结果 id name value 1 a pp 3 b iii 4 b pp 6 c pp 8 c iii 方法1 delete YourTable where [id] not in ( select max([id]) from Your...

去重.. //select count(*) as c from table group by fieldname having c > 1 找出重复

delete from mygame_article where id not in ( select max(id) from mygame_article group by title);

假设表结构为 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列。语...

给你个思路:先建一个临时表,用distinct查询不重复的数据放到新建的表里面,然后把原表数据清空,再把刚才新表的数据插到原表里

吃饭中…… 保留最大的ID: delete from table where id not in(select max(id) from table group by title) 保留最小的ID: delete from table where id not in(select min(id) from table group by title)

delete from kline a where not exists(select 1 from (SELECT 字段1,...,字段n(除id外的所有字段),MIN(id) id FROM kline GROUP BY 字段1,...,字段n(除id外的所有字段) b where a.id = b.id

delete from temp where id in (select id from (select max(id) as id,count(url) as count from temp group by url having count >1 order by count desc) as tab )

网站地图

All rights reserved Powered by www.fltk.net

copyright ©right 2010-2021。
www.fltk.net内容来自网络,如有侵犯请联系客服。zhit325@qq.com