What's the difference between an SQL inner join and equijoin?

Can you please explain the difference between an equijoin and an inner join in SQL?

They are unrelated.

Almost every join is an equijoin, because the condition for matching rows is based on the equality of two values—one from each of the tables being joined. So that's what makes it an equijoin: the ON condition is equality. This includes inner joins and all three types of outer joins.

Inner joins, on the other hand, can be based on equality to match rows, or on some other condition entirely. If it's not an equijoin, then it's usually called a theta join, although to be precise, an equijoin is just one of the possible theta joins; other theta joins use less than, less than or equal, etc., as the comparison operator. As long as the comparison evaluates to TRUE, the matched rows qualify for the join.

Here's an example. Suppose we have a table of cities, and amongst all the columns of data for a city, is one called avg_temp, which gives the city's average temperature. Then we could list our cities, and for each city, give a count of how many cities are hotter.

SELECT this.cityname
     , this.avg_temp
     , COUNT(others.cityname) AS hotter_cities
  FROM cities AS this
  JOIN cities AS others
    ON others.avg_temp > this.avg_temp
    BY this.cityname
     , this.avg_temp

This must, of course, be an outer join, otherwise the hottest city would have no matching rows (no other cities would be hotter).

Look at the join condition in the ON clause. It is not equality, so this is a theta join.

Dig Deeper on Oracle development languages