Between keyword in MS SQL Server


Between keyword search data from table in rage of two values, It requires two values that is from value and to value. We use AND operator to separates two values.

Let consider below list of shopping items, and we are going to apply BETWEEN keyword in this table.

result set for between clause in sql server

SQL Server Between keyword example


Select table rows using BETWEEN keyword / statement.

Select the product from Shopping table where product price between range of 15000 and 25000.

Example

SELECT * FROM tblShoppingList
WHERE Price BETWEEN 15000 AND 25000

Output

between clause example in sql server


SQL Server Not Between keyword example


Select table rows using NOT BETWEEN keyword / statement

Select the product from Shopping table where product price not between range of 15000 and 25000.

Example

SELECT * FROM tblShoppingList
WHERE Price NOT BETWEEN 15000 AND 25000

Output

not between clause example in sql server


Note : What is difference between IN and BETWEEN?
IN : IN keyword filter the data from given values.
BETWEEN : BETWEEN keyword filter the select data from range of two values.