BETWEEN and NOT BETWEEN Operators in SQL
For Complete YouTube Video: Click Here
In this class, we will understand BETWEEN and NOT BETWEEN Operators in SQL.
We have already discussed the concepts of IN and NOT IN operators in SQL.
Table of Contents
BETWEEN and NOT BETWEEN Operators in SQL
BETWEEN Operator in SQL
With Between operator, we can test a list of values.
To understand this, we will consider the table given below.
From the above table, we will try to fetch the details of the students whose salaries are between 200 and 400.
When we use between the values 200 and 400 are also included.
The query is as shown below.
SELECT * FROM students WHERE salary BETWEEN 200 and 400;
The output for the query is as shown below.
NOT BETWEEN Operator in SQL
From the above table, we will try to fetch the details of the students whose salaries are not between 200 and 400.
The query is as shown below.
SELECT * FROM students WHERE salary NOT BETWEEN 200 and 400;
The output for the query is as shown below.