It seems like to combine two or more tables, we can either use join or where. What are the advantages of one over the other?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Any query involving more than one table requires some form of association to link the results from table “A” to table “B”. The traditional (ANSI-89) means of doing this is to:
Write the association between the tables in the WHERE clause
Here’s the query re-written using ANSI-92 JOIN syntax:
From a Performance Perspective:
Where supported (Oracle 9i+, PostgreSQL 7.2+, MySQL 3.23+, SQL Server 2000+), there is no performance benefit to using either syntax over the other. The optimizer sees them as the same query. But more complex queries can benefit from using ANSI-92 syntax:
From a Maintenance Perspective:
There are numerous reasons to use ANSI-92 JOIN syntax over ANSI-89:
From a Design Perspective:
ANSI-92 JOIN syntax is pattern, not anti-pattern:
Conclusion
Short of familiarity and/or comfort, I don’t see any benefit to continuing to use the ANSI-89 WHERE clause instead of the ANSI-92 JOIN syntax. Some might complain that ANSI-92 syntax is more verbose, but that’s what makes it explicit. The more explicit, the easier it is to understand and maintain.