SQL BETWEEN

BETWEEN operator is used in the WHERE clause to select values from a range of data.

BETWEEN SQL syntax

SELECT column FROM table WHERE column BETWEEN value1 AND value2

BETWEEN SQL Example

Given the following table 'people'

namesurnamenickname
HARRYCLARKWHITE
HARRYSMITHJOHNSON
JOHNBROWNANDERSON

Select people whose surname is between 'CLARK' and 'SMITH'

SELECT * FROM people WHERE surname BETWEEN 'CLARK' AND 'SMITH'

namesurnamenickname
HARRYCLARKWHITE
HARRYSMITHJOHNSON

Select people whose surname is not between 'CLARK' and 'SMITH'

SELECT * FROM people WHERE surname NOT BETWEEN 'CLARK' AND 'SMITH'

namesurnamenickname
JOHNBROWNANDERSON