Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 SQL Novice - Stupid Question

Author  Topic 

bturney
Starting Member

2 Posts

Posted - 2010-11-03 : 17:58:53
This is probably a stupid question but what is the difference between the two statements below?

Select
a.field1,
b.field2,
b.field3,
c.field2
from
file1 a,
file2 b,
file3 c
where
a.field1 = b.field1
and b.field2 = c.field1



Select
a.field1,
b.field2,
b.field3,
c.field2
from
file1 a
join file2 b on a.field1 = b.field1
join file3 c on b.field2 = c.field1

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-11-03 : 18:34:44
One is using the ANSI standard, the other is not. Use the second method to avoid issues in future versions of SQL Server.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

jeffw8713
Aged Yak Warrior

819 Posts

Posted - 2010-11-03 : 18:53:05
Tara, actually both are using ANSI standards. The first is ANSI-89 and fully supported in ANSI-92 (and later) for inner joins. The second is ANSI-92 standard.

Either can be used, but I always recommend using the second style because explicitly stating the joins makes it very clear what the intent is. Using the former, it can be harder to separate the join criteria from the where.

Jeff
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-11-03 : 19:05:05
Ah yes! Thanks for the clarification. I've heard that the first method may not be available in future versions, so might as well learn the join syntax now.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

Joziewelz
Starting Member

4 Posts

Posted - 2010-11-03 : 19:13:52
Hi, seems that you may be new to sql like my self. Could you please give me some feedback on my post please.

I am recently laid off from my job and was introduced to SQL. I want to study and get certified in SQL Server 2008 Administration, any suggestions and or study habits I should implement? And is this field for the novice?

Thank you all.
Go to Top of Page

bturney
Starting Member

2 Posts

Posted - 2010-11-04 : 10:55:37
Thanks for the replies...

Go to Top of Page
   

- Advertisement -