Skip
Arish's avatar

33. Using NOT BETWEEN


NOT BETWEEN

Excludes values within a range.

Syntax

sql
1SELECT * FROM students
2WHERE age NOT BETWEEN 12 AND 14;

Example

Students NOT aged 12-14:

sql
1SELECT * FROM students
2WHERE age NOT BETWEEN 12 AND 14;

Returns students aged 11 or below, and 15 or above.

With Marks

sql
1-- Marks outside 70-80 range
2SELECT * FROM students
3WHERE marks NOT BETWEEN 70 AND 80;