?
Solved

SQL JOIN syntax

Posted on 2012-12-25
3
Medium Priority
?
514 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 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 43

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

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

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

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
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.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Suggested Courses

755 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