⚡ 180+ new openings posted today

SQL BETWEEN Operator

The BETWEEN… AND operators in SQL is used to select in-between values from the given range values. The values can be numbers, text, or dates.

Syntax

SELECT column_name
FROM table_name
WHERE column_name BETWEEN value1 AND value2;

Here, value1 is the lower limit and value2 is the upper limit.

Example: Numbers

Suppose we have an Employees table:

IDNameSalary
1Ayush30000
2Mayank45000
3Shivansh60000
4Sakshi75000

To find employees whose salary is between 40,000 and 70,000:

SELECT *
FROM Employees
WHERE Salary BETWEEN 40000 AND 70000;

Output:

IDNameSalary
2Mayank45000
3Shivansh60000

BETWEEN with Dates

BETWEEN can also be used with dates:

SELECT *
FROM Orders
WHERE OrderDate BETWEEN '2026-01-01' AND '2026-01-31';

This selects orders between January 1 and January 31, inclusive.

NOT BETWEEN

To find values outside a range, use NOT BETWEEN:

SELECT *
FROM Employees
WHERE Salary NOT BETWEEN 40000 AND 70000;

This returns employees whose salary is less than 40,000 or greater than 70,000.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top