您好,欢迎访问一九零五行业门户网

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

可以通过在 select 子句中使用 distinct 关键字来实现。 distinct 适用于 select 子句中指定的所有数据字段的组合。
示例我们有已应用的表“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返回结果集的行中如何过滤掉重复的行?的详细内容。
其它类似信息

推荐信息