BETWEEN
Published May 7, 2021Updated Aug 18, 2022
Contribute to Docs
The BETWEEN
operator selects values, inclusive of beginning and end values, within a given range.
Syntax
SELECT *
FROM table
WHERE column BETWEEN value_A AND value_B;
The column
must exist and value_A
and value_B
must define a valid range. BETWEEN
works with numbers, text, or date data types.
Example
The following query returns all rows from the students
table with a gpa
between 0 and 2 (exclusive) in ascending order:
SELECT *FROM studentsWHERE gpa BETWEEN 0.0 AND 1.99ORDER BY gpa;
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.