《mysql必知必會》學習_第七章_20180730_歡

來源:互聯網
上載者:User

標籤:執行   end   同時存在   分享圖片   nbsp   過濾   .com   必知必會   rom   

第七章:資料過濾

P43

select prod_id,prod_price,prod_name from products where vend_id =1003 and prod_price <=10;  #檢索vend_id=1003 並且prod_price<=10 #

select prod_name,prod_price from products where vend_id=1002 or vend_id =1003; #檢索的條件只要滿足vend_id=1002 ,vend_id=1003即可#

P42

select prod_name,prod_price from products where vend_id =1002 or vend_id=1003 and prod_price >=10;#and和or同時存在的時候,優先處理and的操作符,理解為兩個條件:(vend_id=1002) or(vend_id =1003 and prod_price) ,滿足其一即可。

P42

select prod_name,prod_price from products where (vend_id =1002 or vend_id =1003 ) and prod_price>=10; #執行兩個命令:(vend_id=1002,vend_id=1003)和prod_price>=10,圓括弧()的命令優先順序高於and和or #

P43 in操作符 (in取合法值有逗號分開,如(5,8) )

select prod_name,prod_price from products where vend_id in (1002,1003) order by prod_name; #檢索的條件vend_id 在1002到1003這個範圍內#因為vend_id都是整數,所以上面的語句的結果和這個一樣:

select prod_name,prod_price from products where vend_id=1002 or vend_id=1003 order by prod_name; 

但注意,in命令比or執行更快。

P45 

 select prod_name,prod_price from products where vend_id not in (1002,1003) order by prod_name; #not否定了not後面的條件,不檢索(1002,1003) #

 

《mysql必知必會》學習_第七章_20180730_歡

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.