mssql sqlserver between and 关键字用法


摘要:
下文将举例讲述 between and 关键字的用法


between and 关键字需搭配where 关键字,作为sql 脚本的查询条件使用
between and语法如下:

between [参数1] and [参数2]
参数1,参数2:作为数据的边界值
where [列] between [参数1] and [参数2] 等同于 where [列] >=[参数1] and [列] <=[参数2]

————————————————-
例:

 create table A(keyId int identity,name varchar(10))
go
insert into A(name)values('a'),('b'),('c'),('d'),('e')
go

select keyId,name from A where  keyId between 2 and  4 
----between and 脚本等同于 where 条件
select keyId,name from A where keyId >=2 and keyId <=4 

go
truncate table A
drop table A 
mssql_sqlserver_between_and关键字用法

mssql_sqlserver_between_and关键字用法