標籤:文本處理 語句 選擇 like ice upper 函數 解釋 大小
Select distinct productname from custom_
Where product_price between 5 and 10
Order by product_price desc ,product_name
Limit 3 offset 1;
Limit 限定從1行開始選出3行,預設列是從0列開始的。
分號 或\g表示語句結束
Help 或 \h 擷取協助
quit或exit 退出
distinct作用與後面所有列,不能部分使用
查詢order預設升序asc(ascend)
預設 A與a視為相同順序,
*代替所有列
Order by 放在where之後
MySQL預設不區分大小寫
條件中 與字串比較需要加引號限定,與數值比較則不要
空值 null ,選擇匹配時,系統是不匹配其值的,即不會返回
2016/12/25 下午 6:39
where id in (11,13)
where id not in (11,13)
萬用字元:
where pro_name like ‘jet%‘ 樣式匹配jet開頭的產品名
(區分大小寫)
萬用字元:‘%jet%’ 中間包含jet
%代表任一字元,0個或以上個字元, 但不能匹配NULL
_ 匹配 單個字元
note:
萬用字元效率低於其他搜尋
Regex:
where pro_name REGEXP ‘正則‘ 返回包含符合運算式樣式的 行
區分大小寫 加BINARY關鍵詞 如 where pro_name REGEXP BINARY ‘.000‘
mysql 中正則的關鍵詞轉義為‘\\’: \\. 表示. \\- 表示- \\\ 表示\
(mysql自己解釋一個\ ,正則解釋一個\ 。)
note:
where pro_name REGEXP ‘1000‘ 傳回值為‘1000’的行 正則匹配子字串
where pro_name like ‘1000‘ 沒有萬用字元 什麼也不返回 like匹配整個字串
計算字元段:
拼接函數:Concat(,,) 如select concat(vend_name , ‘(‘ , vend_counytry ,‘)‘ ) from vendos order by vend_name
返回如:ACME(USA)
trim() 刪除空格
AS 賦值給其他列
運算:select pro_id, quantity ,item_price ,
quantity*item_price= expanded_price
from orderitems ;
文本處理函數:
select vend_name ,upper(vend_name) AS vend_name_upcase
from vendors;
Rtrim() 右邊的空格
MySQL查詢文法