溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

mysql中的查詢選項怎么用

發(fā)布時間:2021-08-03 15:08:16 來源:億速云 閱讀:112 作者:chen 欄目:編程語言

這篇文章主要講解了“mysql中的查詢選項怎么用”,文中的講解內(nèi)容簡單清晰,易于學(xué)習(xí)與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學(xué)習(xí)“mysql中的查詢選項怎么用”吧!

說明

1、查詢選項,用來對查詢結(jié)果進(jìn)行簡單的數(shù)據(jù)過濾,查詢選項在select關(guān)鍵字之后有兩個互斥。

2、all默認(rèn),表示保留所有記錄(關(guān)鍵字可以不顯示)。distinct去重,重復(fù)記錄(根據(jù)所選字段構(gòu)成的記錄,而非某一字段)

實例

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;

感謝各位的閱讀,以上就是“mysql中的查詢選項怎么用”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對mysql中的查詢選項怎么用這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是億速云,小編將為大家推送更多相關(guān)知識點的文章,歡迎關(guān)注!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI