BETWEEN Predicate
A BETWEEN predicate determines whether a value is:
-
Greater than or equal to a second value
and:
-
Less than or equal to a third value
The predicate evaluates to TRUE if a value falls within the specified range.
SQL syntax
Expression1[NOT] BETWEENExpression2ANDExpression3
Parameters
| Parameter | Description |
|---|---|
|
|
See "Expression Specification" for information on the syntax. Both numeric and non-numeric expressions are allowed in |
Description
-
BETWEENevaluates toFALSEandNOT BETWEENevaluates toTRUEif the second value is greater than the third value. -
Consult the following table if either
Expression2orExpression3isNULLforBETWEENorNOT BETWEEN:Expression2 Expression3 BETWEEN NOT BETWEEN <=Expression1NULLNULLNULL>Expression1NULLFALSETRUENULL>=Expression1NULLNULLNULL<Expression1NULLNULL -
Expression2andExpression3constitute a range of possible values for whichExpression2is the lowest possible value andExpression3is the highest possible value within the specified range. In theBETWEENpredicate, the low value must be specified first.See "Comparison Predicate" for information on comparisons.
-
The
BETWEENpredicate is not supported forNCHARtypes.
Examples
Parts sold for under $250.00 and over $1500.00 are discounted 25 percent.
UPDATE Purchasing.Parts SET SalesPrice = SalesPrice * 0.75 WHERE SalesPrice NOT BETWEEN 250.00 AND 1500.00;