Range Filtering with BETWEEN
Use BETWEEN to determine whether a given value falls within a specified range. The BETWEEN condition’s important characteristics are:
BETWEEN works with character strings, numbers, and datetimes.
The BETWEEN range contains a low value and a high value, separated by AND. The low value must be less than or equal to the high value.
BETWEEN is a convenient, shorthand clause. You can replicate its behavior by using AND:
WHERE test_column BETWEEN low_value AND high_value
is equivalent to:
WHERE (test_column >= low_value) AND (test_column <= high_value)
BETWEEN specifies an inclusive range, in which the high value and low value are included in the search. To specify an exclusive range, which excludes endpoints, use > and ...
Get SQL: Visual QuickStart Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.