Beginner

444. NON-EQUI JOIN

Learn how joins can match records using conditions other than equality.

📘 Lesson 444 of 728 ⏱ 11 min 🎯 Intermediate

A NON-EQUI JOIN matches rows using comparison operators such as greater than, less than, greater than or equal to, or less than or equal to instead of only using equality.

Some business relationships are based on ranges rather than exact matching values.

Match employee salaries to salary grades based on minimum and maximum salary ranges.

SQL
SELECT
    e.EmployeeName,
    e.Salary,
    g.Grade
FROM Employees e
INNER JOIN SalaryGrades g
    ON e.Salary BETWEEN g.MinSalary AND g.MaxSalary;

NON-EQUI JOINs are useful for salary bands, tax slabs, pricing ranges, risk categories, commission structures, and date ranges.

  • NON-EQUI JOIN does not require equality.
  • Comparison operators can define the relationship.
  • BETWEEN is commonly useful for range joins.
  • Range joins are common in business rules.
  • Careful conditions are required to avoid multiple matches.
What is a NON-EQUI JOIN?

A NON-EQUI JOIN matches records using comparison conditions other than simple equality.

Where can NON-EQUI JOIN be useful?

It is useful for ranges such as salary bands, tax slabs, pricing levels, and date intervals.

Have you finished this lesson?

Introduction to SQL – All Lessons