BETWEEN

BrandonDusch's avatar
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 students
WHERE gpa BETWEEN 0.0 AND 1.99
ORDER BY gpa;

All contributors

Contribute to Docs

Learn SQL on Codecademy