过滤数据
使用WHERE子句
SELECT prod_name,prod_price
FROM products
WHERE prod_price = 3.49;
WHERE字句操作符
= 等于
<>不等于
!=不等于
<小于
<=小于等于
!<不小于
>大于
>=大于等于
!>不大于
BETWEEN 在指定的两个值之间
IS NULL为NULL值
范围值检查
SELECT prod_name,prod_price
FROM products
WHERE prod_price BETWEEN 5 AND 10;
AND操作符
SELECT prod_id,prod_price,prod_name
FROM products
WHERE vend_id = 'DLL01' AND prod_price <= 4;
OR操作符
SELECT prod_id,prod_price,prod_name
FROM products
WHERE vend_id = 'DLL01' OR vend_id = 'BRS01';
求值顺序
在处理操作符前,优先处理AND操作符
可以在WHERE语句中使用圆括号
SELECT prod_name,prod_price
FROM products
WHERE (vend_id = 'DLL01' OR vend_id = 'BRS01')
AND prod_price >= 10;
IN操作符
功能与OR相当
SELECT prod_name,prod_price
FROM products
WHERE vend_id IN ('DLL01','BRS01')
ORDER BY prod_name;
NOT操作符
WHERE子句中用来否定其后条件的关键字
SELECT prod_name
FROM products
WHERE NOT vend_id = 'DLL01'
ORDER BY prod_name;