SQL(5) 高階資料過濾

2021-10-06 16:30:16 字數 701 閱讀 9754

select prod_name,prod_price from product where vend_id = 『dell01』 and prod_price<5000;

select prod_name,prod_price from product where vend_id = 『del01』 or vend_id = 『hua01』;

select prod_name,prod_price from product where (vend_id = 『del01』 or vend_id = 『hua01』 ) and prod_price<5000; and 的優先順序高於or,如果不加括號,則會篩選出**小於5000的品牌名稱為hua01的產品及全部品牌名為del01的產品。加括號後篩選結果為hua01及del01兩個品牌**小於5000產品。

select prod_name,prod_price from product where vend_id in ( 『del01』 ,『hua01』);where語句中的 in 用來指定範圍,範圍中的所有值均可進行匹配。in操作符的功能or也可完成。但in 更清楚簡潔。

select prod_name,prod_price from product where not vend_id = 『del01』 order by prod_name;

where 語句中的not用來否定其後跟的所有條件。

《sql必知必會》-學習記錄。

SQL第5課 高階過濾資料

用來聯結或改變wehere子句中的子句的關鍵字,也稱為邏輯操作符。乙個and兩個條件,如果有多個條件,那麼兩個條件之間加乙個and 猜猜區別 select vend id,prod price,prod name from products where vend id dll01 or vend i...

SQL必知必會 5 高階資料過濾

為了進行更強的過濾控制,sql允許給出多個where子句,這些子句有兩種使用方式,即以and子句或or子句的方式使用。注意 1 操作符 用來聯結或改變where子句中的子句的關鍵字,也稱為邏輯操作符。檢索由 商dll01製造且 小於等於4美元的所有產品的名稱和 select prod id prod...

SQL5 條件查詢

1 條件查詢 1 語法 select 查詢列表 3 from 表名 1 where 篩選條件 2 2 分類 a 按條件表示式篩選 條件運算子 例子1 查詢工資大於12000的員工資訊 select from employees where salary 12000 例子2 查詢部門編號不等於90號的...