I agree to TechTarget’s Terms of Use, Privacy Policy, and the transfer of my information to the United States for processing to provide me with relevant information as described in our Privacy Policy.

Please check the box if you want to proceed.

I agree to my information being processed by TechTarget and its Partners to contact me via phone, email, or other means regarding information relevant to my professional interests. I may unsubscribe at any time.

Please check the box if you want to proceed.

By submitting my Email address I confirm that I have read and accepted the Terms of Use and Declaration of Consent.

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
LEFT OUTER
JOIN cities AS others
ON others.avg_temp > this.avg_temp
GROUP
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.

0 comments

Register

Login

Forgot your password?

Your password has been sent to:

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy