当前位置:网站首页>MySQL去重查询
MySQL去重查询
2022-04-21 18:55:00 【万里长江雪】
在使用MySQL时,有时需要查询出某个字段不重复的记录,这时可以使用mysql提供的distinct这个关键字来过滤重复的记录,
实例:
select distinct name,id from user;,这样的结果为:

distinct name,id 这样的mysql 会认为要过滤掉name和id两个字段都重复的记录,如果sql这样写:select id,distinct name from user,这样mysql会报错,因为distinct****必须放在要查询字段的开头。
所以一般distinct用来查询不重复记录的条数。
如果要查询不重复的记录,有时候可以用****group by :
select id,name from user group by name;
group by 是分组查询 关键字
distinct 是去重查询关键字
详情网站:http://www.cnblogs.com/shiluoliming/p/6604407.html
版权声明
本文为[万里长江雪]所创,转载请带上原文链接,感谢
https://blog.csdn.net/fwdwqdwq/article/details/124321731
边栏推荐
猜你喜欢

86 R k-means,层次,EM聚类介绍

Les poignées vous apprennent à construire des composants et des applications

【大话云原生】负载均衡篇-小饭馆客流量变大了

解析创客教育的实践进程

一文读懂Seek Tiger推出创世节点的意义

CheKine 系列高密度脂蛋白(HDL-C)含量检测方案

Cvpr2022 unified upgrade of oral | cosface and arcface, and adaface solves face recognition of low-quality images

SVG系列——2,绘制一些形状

LeetCode1765. Highest point in the map (BFS)
![[ES6] let, const, deconstruction assignment, template string](/img/42/1e57b501799cc019cf652b8aaf5999.gif)
[ES6] let, const, deconstruction assignment, template string
随机推荐
低密度脂蛋白研究丨LDL-C含量检测试剂盒方案
LeetCode1765. Highest point in the map (BFS)
解读自主形机器人的责任感
SVG系列——1,入门级操作
What's a good brand of real wireless headphones? High profile flagship Bluetooth headset
Database advanced learning: introduction to index and BTREE, B + tree, hash
我好菜,发慌
Introduction to IPv6 foundation and common commands
什么品牌的无线耳机质量最好?口碑好的蓝牙耳机推荐
少儿编程培训发展的重要趋势
Leetcode 824.山羊拉丁文
How to detect how many cameras are plugged into the PC? And conduct multi camera synchronous recording?
医疗机器人在AI领域的广泛应用
SVG系列——2,绘制一些形状
Cnpm|npm set image address operation
CVPR 2022 | a new face attribute editing framework based on transformer
leetcode:423. 从英文中重建数字
SSH keygen setting password free login
这玩意叫跳表?
Dry goods | after the interview, how to talk about salary? What are the skills of a high paying offer?