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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 correct sql syntax

Author  Topic 

dev45
Yak Posting Veteran

54 Posts

Posted - 2004-09-29 : 08:54:32
hi,
i have run into the following piece of code

SELECT colA,colB,colC
FROMTable1
INNER JOIN Table2 on Table2.codD = @parameter1 AND Table1.colE = @parameter2

it seems to be working fine but is it correct ? i understand that there should be a WHERE clause (WHERE table2.cold = @parameter1 AND ...), but since there are a lot of queries to change (and test to be redone) do u think it is safe to leave as they are?

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2004-09-29 : 08:59:05
an inner join such as above is equivalent to the below.

SELECT colA,colB,colC
FROMTable1, Table2
WHERE Table2.codD = @parameter1 AND Table1.colE = @parameter2


Other types of JOIN's (LEFT,CROSS,etc) however do not quite have this property.
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2004-09-29 : 09:07:32
the only difference is if it were a LEFT outer join -- then the meaning of the criteria in the join expression versus the WHERE is very different.

- Jeff
Go to Top of Page
   

- Advertisement -