SQL BETWEEN Statement

The SQL BETWEEN statement with the BETWEEN operator is used with the WHERE clause to select a range of data between two values in a SQL statement.

SQL BETWEEN statement

SELECT column_name(s)
FROM table_name
WHERE column_name
BETWEEN value AND value

Database Table “Members”

Id FirstName LastName Email City Phone
1 Gilbert Duncan [email protected] Newark 973-600-3300
2 Elvis Daniels [email protected] Piscataway 862-600-3050
3 Michael Green [email protected] Detroit 732-500-5050
4 Kelvin Graham [email protected] Detroit 732-555-5050

SQL BETWEEN Example

SELECT *
FROM Members
WHERE FirstName
BETWEEN ‘Gilbert’ AND  ‘Kelvin’

RESULT of SQL BETWEEN statement above will be

Id FirstName LastName Email City Phone
2 Elvis Daniels [email protected] Piscataway 862-600-3050
3 Michael Green [email protected] Detroit 732-500-5050

Important: It is important to note that some databases include the test values. So some databases will include the result between the test values including the test values also.

SELECT *
FROM Members
WHERE FirstName
BETWEEN ‘Gilbert’ AND ‘Kelvin’

RESULT of SQL BETWEEN statement above will be

Id FirstName LastName Email City Phone
1 Gilbert Duncan [email protected] Newark 973-600-3300
2 Elvis Daniels [email protected] Piscataway 862-600-3050
3 Michael Green [email protected] Detroit 732-500-5050
4 Kelvin Graham [email protected] Detroit 732-555-5050