?
Solved

SQL JOIN syntax

Posted on 2012-12-25
3
Medium Priority
?
503 Views
Last Modified: 2012-12-25
When doing SQL JOINS is see two different syntax for what seems to be the same thing, one using the JOIN syntax and one not.  See examples.

Code 1
SELECT Address.City, Name.NameFirst
from Address, Name
Where Address.AddressId = Name.AddressId

Code 2
SELECT Address.City, Name.NameFirst
    from Address
    join Name
    on name.addressid = address.addressid

Needless to say there are many variations, but the fundamental difference seems to be using the FROM <table1>, <table2>
versus using JOIN <table2>
Even the variations of Left, Right, inner, outer seem easier managed with the Code 1 concept.

To me same Code 1 seems lots simpler.
0
Comment
Question by:hconant
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 38720406
Was there a question in there somewhere?
0
 

Author Comment

by:hconant
ID: 38720408
The question is, when and why would you need to use the JOIN syntax as both styles seem the same.  And is it simply a matter of style?  Just trying to learn best methods.
0
 
LVL 42

Accepted Solution

by:
pcelba earned 1000 total points
ID: 38720413
Code1 and Code2 is identical for INNER JOINs.
The Code1 is older concept and not all SQL dialects allow to specify OUTER JOIN by operator in WHERE clause.

OTOH, Code1 allows CROSS JOIN which is not available in all SQL dialects supporting JOIN clause...

So, use the way which better fits to you and your SQL engine specifications. Everything else is a work for SQL optimization.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question