MySQL返回结果集的行中如何过滤掉重复的行?

2023年 8月 27日 82.4k 0

MySQL返回结果集的行中如何过滤掉重复的行?

示例

我们有已应用的表“Student” DISTINCT 关键字如下 -

mysql> Select * from student;

+------+---------+---------+-----------+
| Id | Name | Address | Subject |
+------+---------+---------+-----------+
| 1 | Gaurav | Delhi | Computers |
| 2 | Aarav | Mumbai | History |
| 15 | Harshit | Delhi | Commerce |
| 17 | Raman | Shimla | Computers |
| 20 | Gaurav | Jaipur | History |
+------+---------+---------+-----------+

5 rows in set (0.00 sec)

mysql> Select DISTINCT Address from student;

+---------+
| Address |
+---------+
| Delhi |
| Mumbai |
| Shimla |
| Jaipur |
+---------+

4 rows in set (0.00 sec)

mysql> Select DISTINCT * from student;

+------+---------+---------+-----------+
| Id | Name | Address | Subject |
+------+---------+---------+-----------+
| 1 | Gaurav | Delhi | Computers |
| 2 | Aarav | Mumbai | History |
| 15 | Harshit | Delhi | Commerce |
| 17 | Raman | Shimla | Computers |
| 20 | Gaurav | Jaipur | History |
+------+---------+---------+-----------+

5 rows in set (0.00 sec)

mysql> Select DISTINCT name from student;

+---------+
| name |
+---------+
| Gaurav |
| Aarav |
| Harshit |
| Raman |
+---------+

4 rows in set (0.00 sec)

登录后复制

以上就是MySQL返回结果集的行中如何过滤掉重复的行?的详细内容,更多请关注每日运维网(www.mryunwei.com)其它相关文章!

相关文章

Oracle如何使用授予和撤销权限的语法和示例
Awesome Project: 探索 MatrixOrigin 云原生分布式数据库
下载丨66页PDF,云和恩墨技术通讯(2024年7月刊)
社区版oceanbase安装
Oracle 导出CSV工具-sqluldr2
ETL数据集成丨快速将MySQL数据迁移至Doris数据库

发布评论