NON-EQUI joins in SQL

So here's another post about SQL joins. Based on the type of condition we use for joining we distinguish equi joins and non-equi joins.

Simply put:
- equi joins: we're using the equality operator:
tab_a.column_x = tab_b.column_y
- non-equi joins: other operators, like comparison, inequality or BETWEEN are used

While a good portion of the time we use equi joins to, say, lookup the department the employee is part of, non-equi joins are not uncommon either.

Moreover, sometimes we might use both equality and other operators for joining the same table.

Let's look at a simple non-equi join scenario below.

No alt text provided for this image

Found it useful? Subscribe to my Analytics newsletter at notjustsql.com.