The BETWEEN predicate (between_predicate) is a predicate that checks whether a value is within a specified range.
<between_predicate> ::= <expression> [NOT] BETWEEN <expression> AND <expression>
Assume that x, y, and z are the results of the first, second, and third expression (expression). The values x,y,z must be comparable.
|
Result of the Specified Predicate |
x BETWEEN y AND z |
x>=y AND x<=z |
x NOT BETWEEN y AND z |
NOT(x BETWEEN y AND z) |
x, y, or z are NULL values |
x [NOT] BETWEEN y AND z is undefined |
SELECT title, name, zip
FROM customer
WHERE zip BETWEEN '10000' AND '30000'
Selection of customers who live in cities with a zip code between 10000 and 30000
TITLE |
NAME |
ZIP |
Mrs |
Porter |
10580 |
Mrs |
Griffith |
20005 |
Company |
TOOLware |
20019 |
Mr |
Jenkins |
20903 |