// conditional reference

SQL BETWEEN operator

True when the value is greater than or equal to the low bound and less than or equal to the high bound.

Categoría
Condicional
Returns
boolean
In this category
23 of 43

Sintaxis

x BETWEEN low AND high | x NOT BETWEEN low AND high

Soporte del motor

MotorSupportNotas
SQL Server Sí Supported under this name.
PostgreSQL Sí Supported under this name.
MySQL Sí Supported under this name.
SQLite Sí Supported under this name.
Oracle Sí Supported under this name.

Ejemplos

Any engine

SELECT * FROM orders WHERE total BETWEEN 100 AND 500;

Any engine

SELECT * FROM events WHERE created_at >= '2026-11-01' AND created_at < '2026-12-01';

Conviene saberlo

  • Both bounds are inclusive, so BETWEEN 100 AND 500 includes exactly 100 and 500.
  • Date ranges bite: BETWEEN '2026-01-01' AND '2026-12-31' misses everything on Dec 31 after midnight; prefer col >= '2026-01-01' AND col < '2027-01-01'.
  • If the value or a bound is NULL, the result is UNKNOWN and the row drops, even with NOT BETWEEN.
  • Reversed bounds (low > high) are always FALSE; PostgreSQL's BETWEEN SYMMETRIC swaps them instead.

Questions about BETWEEN

Is BETWEEN inclusive?

Yes, on both ends, in every one of the five engines.

How do I filter a whole month?

Half-open: col >= first_day AND col < first_day_next_month; BETWEEN the two first-days misses the last day's timestamps.

What does BETWEEN do with NULL?

UNKNOWN, row filtered; NOT BETWEEN does not rescue it.

Browse every function in the SQL function reference, or see what the SQLly desktop app does for your database.

Cheat sheets for the engines that have it: SQL Server, PostgreSQL, MySQL, SQLite, Oracle.

// fewer lookups

Functions your engine actually has

SQLly's completion lists the built-in functions of the engine you're connected to, whether that's SQL Server, PostgreSQL, MySQL, SQLite or Oracle. Hover a function for help, and signature hints show each argument as you type.