BETWEEN checks whether a value falls inclusively between two boundary values and can be used in JOIN conditions.
Range-based business rules frequently require matching a value to a defined interval.
Match an employee's salary to a salary grade.
SELECT
e.EmployeeName,
e.Salary,
g.GradeName
FROM Employees e
INNER JOIN SalaryGrades g
ON e.Salary BETWEEN g.MinSalary AND g.MaxSalary;
Used in salary bands, tax slabs, pricing tiers, risk categories, and commission structures.
- BETWEEN includes both boundaries.
- It can be used inside JOIN conditions.
- Boundary overlaps can create duplicate matches.
- Careful range design is important.
- For dates, half-open ranges can sometimes be safer.
Can BETWEEN be used in a JOIN?
Yes. BETWEEN can match a value against a range in another table.
Are BETWEEN boundaries inclusive?
Yes. BETWEEN includes both the lower and upper boundary.