SELECT fname, lname
FROM employees
WHERE lname = 'Smith'
<> !=
不等于
<> 'Active'
SELECT fname, lname
FROM employees
WHERE status <> 'Active'
>
大于
> '01 Jan 1995'**
SELECT fname, lname
FROM employees
WHERE hire_date >
'12/31/90'
<
小于
< 100
SELECT fname, lname
FROM employees
WHERE job_lvl < 100
>= !<
大于或等于
>= 'T'
SELECT au_lname
FROM authors
WHERE au_lname >= 'T'
<= !>
小于或等于
<= '01 Jan 1995'**
SELECT fname, lname
FROM employees
WHERE hire_date <=
'01/01/95'
BETWEEN expr1 AND expr2
测试值的范围
BETWEEN
'01 Jan 1995'
AND
'31 Dec 1995'**
SELECT fname, lname
FROM employees
WHERE hire_date
BETWEEN '12/31/90'
AND '12/31/91'
IS [NOT] NULL
测试列的内容或表达式的结果是否为空
IS NULL
SELECT fname, lname
FROM employees
WHERE photo_on_file IS NULL
[NOT] LIKE
执行模式匹配(通常只限于字符数据类型)
LIKE ('MAC%')
SELECT fname, lname
FROM employees
WHERE lname LIKE ('MAC%')
expr1 [NOT] IN (val1, val2, ...)– 或 –expr1 [NOT] IN (subquery)
通过测试 expr1 是出现在值的列表中还是出现在子查询的结果集中,匹配特定值的列表
IN ('SW', 'SE')
supplier_id IN
(subquery)
SELECT fname, lname
FROM employees
WHERE sales_region IN ('SW', 'SE')
SELECT product_name
FROM products
WHERE supplier_id IN
(SELECT supplier_id
FROM supplier
WHERE (country = 'Sweden'))
ANY (SOME)
测试子查询结果集中的一个或多个行是否满足指定的条件(ANY 和 SOME 是同义词;在创建 SQL 语句时,查询和视图设计器将使用 ANY)。
<> ANY (subquery)
SELECT au_lname, au_fname
FROM authors
where city <> any
(SELECT city FROM publishers)
ALL
测试子查询结果集的所有行是否都满足指定的条件
advance > ALL (subquery)
SELECT title FROM titles
where advance > all
(SELECT advance FROM
publishers,titles
where titles.pub_id
= publishers.pub_id
AND pub_name =
'Alogdata Infosystems')
[NOT] EXISTS
测试子查询是否返回任何结果(不只是特定的结果)
EXISTS (subquery)
SELECT product_name
FROM products
WHERE EXISTS
(SELECT * FROM
orders, products
WHERE orders.prod_id
= products.prod_id)