最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
mysql GROUP BY删除查询重复记录
时间:2022-06-29 08:07:50 编辑:袖梨 来源:一聚教程网
我们先来看查询重复记录
代码如下 | 复制代码 |
SELECT * |
删除的话也很简单的了
代码如下 | 复制代码 |
delete from people where peopleid in (select peopleid from people group by peopleid having count (peopleid) > 1) and rowid not in (select min(rowid) from people group by peopleid having count (peopleid )>1) |
例
id name
1 a
2 b
3 c
4 c
5 b
完整语句放出:
代码如下 | 复制代码 |
select *, count(distinct name) from table group by name 结果: id name count(distinct name) |
原来还有更简单的办法啊。
相关文章
- 我的世界树脂砖怎么获得 树脂砖详细信息介绍 09-15
- 我的世界铜粒怎么获得 铜粒获取方法大全 09-15
- 我的世界下界砖有什么用 下界砖合成方法介绍 09-15
- 燕云十六声卷人不倦任务怎么做-万事知卷人不倦任务攻略 09-15
- 我的世界附魔之瓶有什么用 附魔之瓶获取途径介绍 09-15
- 我的世界骨粉怎么获得 骨粉多种用途介绍 09-15