02 检索不同的行 distinct

distinct  的意思就是“不同的,有区别的”

SELECT DISTINCT products.vend_id FROM products;
DISTINCT  必须放在列名的前面。
如果有多个列,DISTINCT会对多个列都产生作用。
举例:
如果给出sql如下
select distinct vend_id,prod_price  from products;

此时如果有两条数据vend_id prod_price两列数据完全一致时,会只返回一条数据。
只要有一列数据不一样两条数据就会被都返回。

posted @ 2019-06-20 22:23  小能熊  阅读(226)  评论(0)    收藏  举报