Curriculum
Course: SQL
Login

Curriculum

SQL

SQL References

0/80

MySQL Functions

0/139

SQL Server Functions

0/84

SQL Quick Ref

0/1
Text lesson

BETWEEN

BETWEEN

The BETWEEN command enables the selection of values falling within a specified range, inclusive of numbers, text, or dates.

The BETWEEN command inclusively selects values, including both the beginning and end values.

In the following SQL statement, all products with prices ranging from 10 to 20 are selected.

Example

SELECT * FROM Products
WHERE Price BETWEEN 10 AND 20;

To showcase products beyond the range mentioned in the previous example, employ the NOT BETWEEN operator.

Example

SELECT * FROM Products
WHERE Price NOT BETWEEN 10 AND 20;

The provided SQL statement retrieves all products with a ProductName falling within the range from ‘Carnarvon Tigers’ to ‘Mozzarella di Giovanni’.

Example

SELECT * FROM Products
WHERE ProductName BETWEEN ‘Carnarvon Tigers’ AND ‘Mozzarella di Giovanni’
ORDER BY ProductName;