distinct应用到多个字段的时候,其应用的范围是其后面的所有字段,而不只是紧挨着它的一个字段,而且distinct只能放到所有字段的前面

如下语句是错误的:

SELECT country, distinct province from person; // 该语句是错误的


distinctNULL是不进行过滤的,即返回的结果中是包含NULL值的。

ALL不能同时使用

默认情况下,查询时返回所有的结果,此时使用的就是all语句,这是与distinct相对应的,

 

 对*的处理

*代表整列,使用distinct对*操作

sql 
select DISTINCT * from person 

相当于

select DISTINCT id, `name`, country, province, city from person;

相关文章:

  • 2021-11-23
  • 2022-12-23
  • 2021-05-28
  • 2021-11-29
  • 2021-10-12
  • 2022-02-01
  • 2021-09-07
  • 2021-05-31
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-04
  • 2022-01-30
  • 2021-04-08
  • 2022-12-23
相关资源
相似解决方案