示例
我们有已应用的表“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)其它相关文章!