找回密码
 免费注册

mysql数据库distinct:去除结果集中重复的数据

[复制链接]
发表于 2022-11-27 21:04:23 | 显示全部楼层 |阅读模式
mysql数据库distinct:去除结果集中重复的数据

查询语句中的选项有两个:
1、     all:显示所有数据 【默认】
2、     distinct:去除结果集中重复的数据
  1. mysql> select all stuaddress from stu;
  2. +------------+
  3. | stuaddress |
  4. +------------+
  5. | 北京           |
  6. | 北京           |
  7. | 天津           |
  8. | 河南           |
  9. | 河北          |
  10. | 北京           |
  11. +------------+
  12. 6 rows in set (0.00 sec)

  13. -- 去除重复的项
  14. mysql> select distinct stuaddress from stu;
  15. +------------+
  16. | stuaddress |
  17. +------------+
  18. | 北京           |
  19. | 天津           |
  20. | 河南           |
  21. | 河北          |
  22. +------------+
  23. 4 rows in set (0.00 sec)
复制代码


QQ|Archiver|小黑屋|网站地图|深圳市金黑网络技术有限公司 ( 粤ICP备2021124338号|粤公网安备 44030702003689号 )

GMT+8, 2026-8-8 15:03 , Processed in 0.043275 second(s), 22 queries .

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表