www.fltk.net > mysql 查找出重复数据 然后把删除重复的数据 保留一条

mysql 查找出重复数据 然后把删除重复的数据 保留一条

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); 随手写了个,前半...

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 )

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

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

DELETE FROM sheet3 WHERE id in ( SELECT a.手机 FROM sheet3 a left join t_cus_info b on a.`手机`= b.F_PHONE) sheet3的id必须是手机

例如: 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...

这个需要分情况。 1,你的数据库表中有主键,且主键上面的数据为唯一值。也就是没有重复值。 那么你在删除的时候,将这个唯一值作为条件进行删除。

delete from dep where id not in ( select * from (select max(id) from dep group by id having count(id )>1) b);

select name from stu group by name;去重查名

select distinct question_type from question

网站地图

All rights reserved Powered by www.fltk.net

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