📜  运算符之间的SQL Server

📅  最后修改于: 2020-12-02 04:55:04             🧑  作者: Mango

条件之间的SQL Server(运算符)

SQL Server BETWEEN运算符用于在SELECT,INSERT,UPDATE或DELETE语句中检索指定范围内的值。

句法:

expression BETWEEN value1 AND value2;

参数说明

表达式:指定列或计算。

value1和value2:这些值指定表达式用于比较的包含范围。

具有数值的BETWEEN运算符

从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; 

输出:

带NOT运算符的BETWEEN运算符符

从满足以下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;

输出: