?
Solved

SQL - Join table a and table b on a.code = b.code Vs from table a, table b where a.code = b.code

Posted on 2012-03-15
5
Medium Priority
?
295 Views
Last Modified: 2012-06-27
I am trying to understand the difference between Join table a and table b on a.code = b.code Vs from table a, table b where a.code = b.code.
Is there any difference or when will they be different?

I am using SQL Server 2008 R2
0
Comment
Question by:tommym121
5 Comments
 
LVL 29

Assisted Solution

by:Paul Jackson
Paul Jackson earned 400 total points
ID: 37725892
There is no difference.
0
 
LVL 61

Assisted Solution

by:HainKurt
HainKurt earned 400 total points
ID: 37726139
there is difference :)

select * from Join mytable1 a and mytable2 b on a.code = b.code

above is not correct syntax, gives error

select * from mytable1 a, mytable2 b where a.code = b.code

above is correct...

select * from mytable1 a inner join mytable2 b on a.code = b.code

above is also correct and same as the other one...
0
 
LVL 75

Assisted Solution

by:Anthony Perkins
Anthony Perkins earned 800 total points
ID: 37726163
If that is all it is, then the QO in SQL Server is smart enough to recognize the old syntax as a JOIN.  However, I would encourage you to start using the newer syntax, it is only a question of time before it is no longer supported.  There are also some edge cases where I have seen that mixing the syntax produces bad performance.
0
 

Accepted Solution

by:
gnetgnet earned 400 total points
ID: 37726257
These are the same
0
 

Author Closing Comment

by:tommym121
ID: 37729740
Thanks
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

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

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
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
Suggested Courses

831 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