BETWEEN operator is equal to two individual comparisons, which are connected with the Boolean operator AND : Between AND « Select Query « SQL Server / T-SQL






BETWEEN operator is equal to two individual comparisons, which are connected with the Boolean operator AND

1> CREATE TABLE project   (project_no   CHAR(4) NOT NULL,
2>                         project_name CHAR(15) NOT NULL,
3>                         budget FLOAT NULL)
4>
5> insert into project values ('p1', 'Search Engine',        120000.00)
6> insert into project values ('p2', 'Programming Language', 95000.00)
7> insert into project values ('p3', 'SQL',                  186500.00)
8> GO

(1 rows affected)
Msg 8152, Level 16, State 14, Server JAVA2S\SQLEXPRESS, Line 6
String or binary data would be truncated.
The statement has been terminated.

(1 rows affected)
2>
3> --BETWEEN operator is logically equal to two individual comparisons, 
which are connected with the Boolean operator AND.
4>
5> SELECT project_name, budget FROM project WHERE budget between 95000 AND 120000
6> GO
project_name    budget
--------------- ------------------------
Search Engine                     120000

(1 rows affected)
1>
2> SELECT project_name, budget FROM project WHERE budget >= 95000 AND budget <= 120000
3> GO
project_name    budget
--------------- ------------------------
Search Engine                     120000

(1 rows affected)
1>
2> drop table project
3> GO

           
       








Related examples in the same category

1.BETWEEN operator specifies a range: determines the lower and upper bounds of qualifying values
2.Use 'Between ... and' operator on a date data type
3.'Between and' for a number data type
4.Not 'Between...and'