English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Usage and examples of SQL BETWEEN keyword

SQL Keywords Reference

BETWEEN

The BETWEEN command is used to select values within a given range. The values can be numeric, text, or dates.

The BETWEEN command is inclusive: it includes both the start value and the end value.

The following SQL statement selects rows where the price is between10and20 and all products between:

 SELECT * FROM Products
WHERE Price BETWEEN 10 AND 20;

To display products outside the range of the previous example, use NOT BETWEEN:

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

The following SQL statement selects all products with ProductName between 'Carnarvon Tigers' and 'Mozzarella di Giovanni':

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

SQL Keywords Reference