Author Topic: Whats the difference bet an equijoin & an inner join in SQL?  (Read 164 times)

0 Members and 1 Guest are viewing this topic.

Offline rpmolecule

  • Full Member
  • *
  • Posts: 235
  • Karma: +2/-0
  • Seize the Day!
    • View Profile
Whats the difference bet an equijoin & an inner join in SQL?
« on: December 09, 2008, 02:58:30 AM »
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.

Techronnati | where technology never sleeps

Whats the difference bet an equijoin & an inner join in SQL?
« on: December 09, 2008, 02:58:30 AM »

Mountain View


Related Topics

  Subject / Started by Replies Last post
2 Replies
Last post October 18, 2008, 05:49:57 AM
by Transformer10
0 Replies
Last post September 18, 2008, 03:08:14 AM
by JusticeLeague
0 Replies
Last post November 08, 2008, 06:21:30 AM
by MrSpecialist
0 Replies
Last post November 27, 2008, 02:13:40 AM
by MrSpecialist
0 Replies
Last post July 08, 2009, 01:56:26 AM
by MrSpecialist

Posting Disclaimer: Any individual may post a message in this forum and may do so anonymously. Therefore, the sole author is exclusively and entirely responsible for all opinions in that message. They do not represent the official opinions of Techronnati, its administrators or moderators or the Techronnati Management. Techronnati is merely acting as an impartial conduit for constitutionally protected free speech and is not responsible and will not be held liable for the content of such messages. All images and service logos are trademarks of their respective owners.