loading..
Русский    English
18:28

BETWEEN predicate

Syntax

  1. BETWEEN::=
  2. < expression TO test > [NOT] BETWEEN
  3. < begin_expression > AND < end_expression >

BETWEEN predicate specifies the inclusive range to test the expression values. The range is defined by boundary expressions with AND keyword between them. Naturally, all the expressions in BETWEEN predicate must be the same data type, as in the case of comparison predicate.

The predicate

  1. exp1 BETWEEN exp2 AND exp3

is equal to the predicate

  1. exp1 >= exp2 AND exp1 <= exp3

And the predicate

  1. exp1 NOT BETWEEN exp2 AND exp3

is equal to the predicate

  1. NOT (exp1 BETWEEN exp2 AND exp3)

If the value of the predicate exp1 BETWEEN exp2 AND exp3 is TRUE, it does not generally mean that the value of predicate exp1 BETWEEN exp3 AND exp2 is TRUE also, because the first one may be interpreted as the predicate

  1. exp1 >= exp2 AND exp1 <= exp3

while the second one may be considered as

  1. exp1 >= exp3 AND exp1 <= exp2

Example 5.2.3

Find model and processor speed of computers priced between and including $400 through $600:

Console
Execute
  1. SELECT model, speed
  2. FROM PC
  3. WHERE price BETWEEN 400 AND 600;

model speed
1232 500
1233 500
1232 500

Bookmark and Share
Tags
aggregate functions Airport ALL AND AS keyword ASCII AVG Battles Bezhaev Bismarck C.J.Date calculated columns Cartesian product CASE cast CHAR CHARINDEX Chebykin check constraint classes COALESCE common table expressions comparison predicates Computer firm CONSTRAINT CONVERT correlated subqueries COUNT CROSS APPLY CTE data type conversion data types database schema DATEADD DATEDIFF DATENAME DATEPART DATETIME date_time functions DDL DEFAULT DEFAULT VALUES DELETE DISTINCT DML duplicates edge equi-join EXCEPT exercise (-2) More tags
The book was updated
month ago
шторы бархатные Brotsy Home . Домен heidun.ru: купить в магазине доменных имен Рег.ру
©SQL-EX,2008 [Evolution] [Feedback] [About] [Links] [Team]
All right reserved.