BETWEEN keeps the values that fall inside a range. Both ends of the range count as inside it.
SELECT column1, column2FROM table_nameWHERE column1 BETWEEN low_value AND high_value;BETWEEN 10 AND 20 means exactly the same as >= 10 AND <= 20. Put the lower value first; written the other way round, the range is empty.
The examples use the Productions and Invoices tables from the example database.
Numbers
Section titled “Numbers”Budgets from 3.9 million to 11 million, both ends included:
SELECT Title, BudgetFROM ProductionsWHERE Budget BETWEEN 3900000 AND 11000000;| Title | Budget |
|---|---|
| Quarry Lane | 7,200,000 |
| Saltmarsh | 3,900,000 |
| Six Bells | 11,000,000 |
Saltmarsh and Six Bells sit exactly on the ends of the range, and are kept.
NOT BETWEEN keeps everything outside the range:
SELECT Title, BudgetFROM ProductionsWHERE Budget NOT BETWEEN 3900000 AND 11000000;| Title | Budget |
|---|---|
| The Lantern Keepers | 18,500,000 |
| Fennick’s Return | 850,000 |
Dates work the same way. The invoices dated from 5 to 11 March 2025:
SELECT InvoiceID, Supplier, InvoiceDateFROM InvoicesWHERE InvoiceDate BETWEEN '2025-03-05' AND '2025-03-11';| InvoiceID | Supplier | InvoiceDate |
|---|---|---|
| 1002 | Kestrel Catering | 2025-03-06 |
| 1003 | Ashby Camera Hire | 2025-03-11 |
Writing dates as YYYY-MM-DD is the safest form, since every database reads it the same way. Microsoft Access also accepts dates between hash signs, as in #03/05/2025#.
On text, BETWEEN compares in alphabetical order, which can surprise you at the top end of a range:
SELECT TitleFROM ProductionsWHERE Title BETWEEN 'Q' AND 'S';| Title |
|---|
| Quarry Lane |
Saltmarsh is missing because it sorts after the single letter S, just as “Sa” comes after “S” in a dictionary. To include every title starting with S, the range has to end beyond them, for example at 'T', or the condition can be written as Title >= 'Q' AND Title < 'T'.