《SQL必知必会》:高级数据过滤 WHERE AND OR IN NOT
程序员文章站
2022-05-03 13:17:10
...
1. AND操作符
-- AND操作符
SELECT
prod_id,
prod_price,
prod_name
FROM
Products
WHERE
vend_id = '1001'
AND prod_price <= 10;
2. OR操作符
-- OR操作符
SELECT
prod_name,
prod_price
FROM
Products
WHERE
vend_id = '1001'
OR vend_id = 'ANV01';
3.组合使用OR和AND
-- 组合使用
SELECT
prod_name,
prod_price
FROM
Products
WHERE
( vend_id = '1001' OR vend_id = '1003' )
AND prod_price >= 10;
4. IN操作符
-- IN操作符
SELECT
prod_name,
prod_price
FROM
Products
WHERE
vend_id IN ( '1001', '1002' )
ORDER BY
prod_name;
5. NOT操作符
-- NOT操作符
SELECT
prod_name
FROM
Products
WHERE
NOT vend_id = '1001'
ORDER BY
prod_name;
上一篇: 跨域问题
下一篇: manacher入门&模板