Possible Duplicate:
Explicit vs implicit SQL joins
I have two queries in SQL Server.
First query:
Select *
From Stack, Overflow
Where Stack.Id = Overflow.StackId
Second query:
Select *
From Stack
Inner Join Overflow On Overflow.StackId = Stack.Id
These two queries return the same results.
So what is the difference between this two queries in terms of performance?
And which one do you prefer?
Use query #2 – it’s the proper ANSI/ISO SQL Standard
JOINsyntax, and is preferred over #1.For one: your JOIN condition is where it belongs – on the
JOIN– and doesn’t clutter up yourWHEREclause. YourWHEREclause should contain only things that you actually use to constrain your result set.And secondly: since you have to define your
JOINcondition on the JOIN, you’re less likely to “forget” about it and unwantingly produce a cartesian product.And lastly: since you define
INNER JOINorLEFT OUTER JOIN, your query becomes more readable and easier to udnerstand – for someone else looking at your query, and for yourself in six months when you have to go back and maintain your code.