The SQLite BETWEEN
clause is used to extract values within a given range.
SQLite BETWEEN has the same syntax as in SQL Server
, it is used for records between two defined values.
Note that BETWEEN is written after the WHERE clause, and uses the AND
clause to fix the given range.
Syntax
The SQLite BETWEEN syntax is as follows:
SELECT column_name1, column_name2, ... FROM table_name WHERE column_name BETWEEN low_range AND high_range;
Example
Table of student_address
address_id | city | country |
---|---|---|
100 | San Antonio | US |
101 | San Jose | US |
102 | Philadelphia | US |
103 | Austin | US |
104 | Boston | US |
105 | Seattle | US |
For example, to return the student address in the range between 102 and 104, use the keyword BETWEEN followed by the given range.
SELECT address_id, city, country FROM student_address WHERE address_id BETWEEN 102 AND 104;
Output
address_id | city | country |
---|---|---|
102 | Philadelphia | US |
103 | Austin | US |
104 | Boston | US |