SQL Range Operator

The range operator is used to retrieve data that can be extracted in ranges. The range operators are BETWEEN and NOT BETWEEN.

The BETWEEN keyword in the WHERE clause specifies an inclusive range to search. Whereas the NOT BETWEEN keyword is used to exclude rows from the specified range the result set.


Example: SELECT Title FROM Titles WHERE Advance BETWEEN 2000 AND 5000
In the above query, the search condition compares a column to a specific range.

BETWEEN in SQL

The NOT BETWEEN list operator excludes the specified range from the result set. Consider the following example: SELECT Title FROM Titles WHERE Advance NOT BETWEEN 4000 AND 5000

NOT BETWEEN in SQL

Here, the result is based on the search condition specified in WHERE clause and exclude the range specified with the NOT BETWEEN operator.