mysql查询选项如何理解
时间:2023-10-16 18:06:56阅读数:0
mysql查询选项说明
1、查询选项,用来对查询结果进行简单的数据过滤,查询选项在select关键字之后有两个互斥。
2、all默认,表示保留所有记录(关键字可以不显示)。
distinct去重,重复记录(根据所选字段构成的记录,而非某一字段)
mysql查询选项实例
create table t_6( id int primary key auto_increment, goods_name varchar(50) not null, goods_price decimal(10, 2) default 0.00, goods_color varchar(20), goods_weight int unsigned comment '重量,单位克' ) charset utf8; insert into t_6 values(null, 'mate10', 5499.00, 'blue', 320),(null, 'mate10', 5499.00, 'gray', 320),(null, 'nokia3301', 1299, 'black', 420); # 考虑所有字段的去重(不含逻辑主键) select distinct goods_name, goods_price, goods_color, goods_weight from t_6; select goods_name, goods_price, goods_color, goods_weight from t_6; # 保留所有 # 不考虑颜色去重 select distinct goods_name, goods_price, goods_weight from t_6; select all goods_name, goods_price, goods_weight from t_6;
相关文章