Use the BETWEEN predicate to compare a value with a range of values.
Following is the syntax diagram for a BETWEEN predicate:.
►►─ expression ─┬───────┬─ BETWEENexpressionANDexpression ────────────────────►◄ └─ NOT ─┘
Description
Specify an expression. For more information about expressions, see Expressions.
Introduces the range of values for the comparison.
Joins the lower and upper limits of the value range.
A keyword. Use NOT to specify values that are not within the lower and upper limits of the value range.
The following table shows BETWEEN predicates and the search conditions to which they are equivalent.
|
The BETWEEN predicate: |
is equivalent to the search condition: |
|---|---|
|
value-1 BETWEEN value-2 AND value-3 |
value-1 >= value-2 AND value-1 <= value-3 |
|
value-1 NOT BETWEEN value-2 AND value-3 |
NOT (value-1 BETWEEN value-2 AND value-3) |
Example
The result of the following BETWEEN predicate is true only if the value of SALARY is greater than or equal to $25,000, or is less than or equal to $50,000. If the value of SALARY is not within the specified range, the result of this BETWEEN predicate is false.
SALARY BETWEEN 25000 AND 50000
|
Copyright © 2014 CA.
All rights reserved.
|
|