📅  最后修改于: 2020-12-02 04:55:04             🧑  作者: Mango
SQL Server BETWEEN运算符用于在SELECT,INSERT,UPDATE或DELETE语句中检索指定范围内的值。
句法:
expression BETWEEN value1 AND value2;
表达式:指定列或计算。
value1和value2:这些值指定表达式用于比较的包含范围。
从ID在7到13之间的“ Employees”表中检索所有雇员。
SELECT *
FROM [javatpoint].[dbo].[Employees]
WHERE id BETWEEN 7 AND 13;
输出:
要么
SELECT *
FROM [javatpoint].[dbo].[Employees]
WHERE id >= 7
AND id <= 13;
输出:
从满足以下BETWEEN NOT条件的“ Employees”表中检索所有雇员。
SELECT *
FROM [javatpoint].[dbo].[Employees]
WHERE id NOT BETWEEN 7 AND 11;
输出:
要么
SELECT *
FROM [javatpoint].[dbo].[Employees]
WHERE id < 7
OR id > 11;
输出: