MySQL查詢文法

來源:互聯網
上載者:User

標籤:文本處理   語句   選擇   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查詢文法

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.