T-SQL BETWEEN 谓词
BETWEEN谓词是检查一个值或字段值是否在指定的范围内,当括这两个指定的边界值。
下面演示,是搜索出年龄23岁至30岁的会员:
SELECT [MemberId],[Job],[Age],[Salary] FROM dbo.Member WHERE [Age] BETWEEN 23 AND 30
执行结果:
如果不包含此范围记录需要在BETWEEN之前加上NOT,如:
SELECT [MemberId],[Job],[Age],[Salary] FROM dbo.Member WHERE [Age] NOT BETWEEN 23 AND 30
执行结果: