MySQL之過濾資料

2021-08-20 01:31:54 字數 834 閱讀 1642

1 使用where字句:資料根據where子句指定的搜尋條件進行過濾。

select prod_name, prod_price from products where product_price=2.50;

where子句的位置:在同時使用order by 和where子句時,應該 order by位於where之後,否則會產生錯誤。

2 where子句操作符:

= 等於; <>不等於; != 不等於; < 小於;

<= 小於等於; > 大於; >= 大於等於;

between and    指定在兩值之間。

3 範圍值檢查:select prod_name, prod_price from products where prod_price between 5 and 10;

4 空值檢查:select prod_name from products where prod_price is null; 

5 組合where子句:以and子句的方式或者or子句的方式使用。

篩選出**為10美元(含)以上且由1002或1003製造的所有產品:

select prod_name, prod_price from products where (vend_id=1002 or vend_id=1003) and prod_price>=10;

這裡由於使用圓括號具有較高優先的計算次序,所以先運算括號裡的。

6 in操作符:select prod_name, prod_price from products where vend_id in(1002, 1003) order by prod_name;

一般來說,in和or的功能是一樣的。

SQL基本操作之過濾資料

sql基本操作之過濾資料 where子句操作符 我們一般不會想獲得所有行的列值,而是選取我們所需要的 sql提供了where子句實現過濾資料的功能 如在customers表中提取使用者名為fun4all的列 單引號代表字串 select from customers where cust name ...

SQL之過濾資料 where子句

select prod id,prod price from products where prod price 3.49 檢索products表中兩個列,只返回prod price值等於3.49的行。注意 由於資料庫軟體的指定。結果可能是3.490,3.4900。注意 並非所有資料庫軟體都支援所有...

jQuery之過濾元素

還是那句話,這些知識乙個小小的練習,更多的請看jquery手冊 在jquery物件中的元素物件陣列中過濾出一部分元素來 1.first 2.last 3.eq index index 4.filter selector 5.not selector 6.has selector 需求 1.ul下li...