Solved

SQL JOIN syntax

Posted on 2012-12-25
3
459 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
3 Comments
 
LVL 74

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 41

Accepted Solution

by:
pcelba earned 250 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now