www.fltk.net > mysql删除重复记录

mysql删除重复记录

例如: 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 * FROM product p1 WHERE p1.pid in ( SELECT MIN(p2.pid) FROM product p2 group by pname having count(*)>1 ); 先用这个语句看一下是不是对的 再把select * 改为delete

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

直接拿1楼的来改吧, delete from zhszty_ebook where id not in( select * from (select max(id) from zhszty_ebook group by url ) as tmp);------------mysql有个特性,对于表进行修改,删除操作,子查询不能和外层的查询的表一样,所以在加...

数据量不是很大的话可以用这个: select * from 表名 where id not in (select m.id from (select min(id) id from 表名 group by phone)m) 把表名换成你这个的表名

删除重复行sql,将会删除所用重复的数据,保留一条不重复的数据 ALTER IGNORE TABLE your_tableADD UNIQUE INDEX idx_name (cols_a, cols_b, cols_c, cols_d, cols_e);

方法有很多,这里介绍两种 方法一、如果要保留id的最小值,例如: 数据:执行sql:select count(*) as count ,name,id from ceshi group by name<img 最后要删除的sql为:delete from ceshi where id not in (select count(*) as count ,n...

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

不建议直接删除,养成良好的习惯(删除更麻烦),以下是将去重后的数据转移到另一张表代码: Insert into 表名(列名)select distinct 列名 from 表名 你可以按照去重的思路,删除重复数据

delete from `mygame_article` where title in (select title from `mygame_article` group by id having count(title) > 1) and id not in (select max(id) from `mygame_article` group by title having count(title) > 1); 随手写了个,前半...

网站地图

All rights reserved Powered by www.fltk.net

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