Solved

SQL JOIN syntax

Posted on 2012-12-25
3
471 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 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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

863 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

21 Experts available now in Live!

Get 1:1 Help Now