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

select userid,username,userlevel from tb where userid not in(select userid from tb group by username,userlevel having count(1)=1)先找出没有重复的userid,然后过滤这些userid,其余的就是有重复的了

-- 保留相同A值的最小id行 select * from table_a a where not exists ( select 1 from table_a b where b.A = a.A and b.id < a.id )

使用DISTINCT关键字即可。 格式如下: SELECT DISTINCT 列名 FROM 表名;

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

SELECT city_name, title, COUNT(*) FROM tuan_info GROUP BY city_name, title HAVING COUNT(*) >1

稍等,我在看

爱应用团队为你解答 http://jingyan.baidu.com/article/73c3ce28ebed94e50343d9fc.html 望采纳

SELECT* , SUM(num) as '总数'FROMtd_textWHERENAME IN ( SELECT NAME FROM td_text GROUP BY NAME HAVING count(NAME) > 1 )GROUP BY `name`td_text 表数据: 执行sql后

SELECT*, count(t1.stu_id) AS ctFROMtable AS t1GROUP BYt1.stu_idHAVINGct > 1// table 替换为你的表名

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