create table tb(ID int, LOW int, HIGH int, VALUE varchar(10)) insert into tb values(1 , 1 , 3 , 'A') insert into tb values(2 , 4 , 6 , 'B') insert into tb values(3 , 7 , 9 , 'C') godeclare @i as int set @i = 1select * from tb where low <= @i and high >= @i /* ID LOW HIGH VALUE ----------- ----------- ----------- ---------- 1 1 3 A */set @i = 4 select * from tb where low <= @i and high >= @i /* ID LOW HIGH VALUE ----------- ----------- ----------- ---------- 2 4 6 B */drop table tb
insert into tb values(1 , 1 , 3 , 'A')
insert into tb values(2 , 4 , 6 , 'B')
insert into tb values(3 , 7 , 9 , 'C')
godeclare @i as int
set @i = 1select * from tb where low <= @i and high >= @i
/*
ID LOW HIGH VALUE
----------- ----------- ----------- ----------
1 1 3 A
*/set @i = 4
select * from tb where low <= @i and high >= @i
/*
ID LOW HIGH VALUE
----------- ----------- ----------- ----------
2 4 6 B
*/drop table tb