- 5.1 组合WHERE子句
- 5.1.1 AND操作符
- SELECT prod_id, prod_price, prod_name
- FROM products
- WHERE vend_id = 'DLL01' AND prod_price <= 4;
- 5.1.2 OR操作符
- SELECT prod_name, prod_price
- FROM products
- WHERE vend_id = 'DLL01' OR vend_id = 'BSRS01';
- 5.1.3 求值顺序
- SELECT prod_name, prod_price
- FROM products
- WHERE (vend_id = 'DLL01' OR vend_id = 'BRS01')
- AND prod_price >= 10;
- 使用圆括号对操作符进行明确分组。
- 5.2 IN操作符
- SELECT prod_name, prod_price
- FROM products
- WHERE vend_id IN ('DLL01', 'BRSS01')
- ORDER BY prod_name;
- 5.3 NOT操作符
- SELECT prod_name
- FROM products
- WHERE NOT vend_id = 'DLL01'
- ORDER BY prod_name;
- 5.4 小结
- 这一课讲授如何用AND和OR操作符组合成WHERE子句,还讲授了如何明确地管理求值顺序,
- 如何使用IN和NOT操作符。