1.检索数据
1.1 distinct
##用于检索出单一的行值 select distinct vend_id from products. ##distinct 不止作用于其后置字段,它会查出所有列组合情况下单一的列。 select distinct vend_id,vend_name from products. mysql> select * from test; +----+------+-------+ | id | name | photo | +----+------+-------+ | 1 | tony | photo | | 1 | tom | photo | | 2 | tony | photo | | 2 | tom | photo | | 2 | tom | photo | +----+------+-------+ 5 rows in set mysql> select distinct id,name from test; +----+------+ | id | name | +----+------+ | 1 | tony | | 1 | tom | | 2 | tony | | 2 | tom | +----+------+ 4 rows in set mysql> select distinct id,photo from test; +----+-------+ | id | photo | +----+-------+ | 1 | photo | | 2 | photo | +----+-------+ 2 rows in set
1.2 多个字段倒序
多个字段想使用倒序时,必须为每个字段单独使用倒序,否则不会生效。
本博客所有文章除特别声明外,均采用 CC BY-SA 3.0协议 。转载请注明出处!