btcq.net
当前位置:首页 >> mysql 删除重复数据 >>

mysql 删除重复数据

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

应该是这么写的,你备份数据之后试试 delete from cars where id not in( select id from (select id,max(pici) from cars group by xinghao)a )

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

换个思路, 你再新建一个表,表里的字段跟你这个表的字段一样。。 然后 insert into select 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); 随手写了个,前半...

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

大侠,group by 一下不就行了, select * from question group by question_type

其实你会用英文搜索的话。可以很方便在stack overflow上 找到相关的信息 真的学CS的就不要用百度了 用google你会发现一个不一样的世界的 随便贴一个 sql - How can I remove duplicate rows? 稍微讲一下其中一个思路(里面有很多很好的答案 你可...

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

网站首页 | 网站地图
All rights reserved Powered by www.btcq.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com