SELECT * FROM customers -- WHERE state = 'VA' OR state = 'GA' OR state = 'FL' -- 用IN改写: WHERE state IN ('VA', 'GA', 'FL') -- WHERE state NOT IN ('VA', 'GA', 'FL') -- 返回不在这些州的 records
-- 这样是错的:WHERE state = 'VA' OR 'GA' OR 'FL' -- 因为我们不能用OR连接布尔表达式state = 'VA'和字符串'GA'
BETWEEN 运算符
1 2 3 4 5
SELECT * FROM customers -- WHERE points >= 1000 AND points <=3000 -- 改写为: WHERE points BETWEEN1000AND3000
1 2 3 4
-- 也可用于非数值 SELECT * FROM customers WHERE birth_date BETWEEN"1990-01-01"AND"2000-01-01"