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 Programming
 inner join can be written in four ways? is it true

Author  Topic 

learning_grsql
Posting Yak Master

230 Posts

Posted - 2012-08-28 : 10:54:06
I used to write a inner join query in four ways and so far I have always assumed all four will give same output.

But I'm not sure if that is really true or it has any unknown effects.


First :

Update C set C.field1 = D.field1 from tblhelptable D
join tblmaintable C on C.field2 = D.field2

Second :
Update C set C.field1 = D.field1 from tblmaintable C
join tblhelptable D on C.field2 = D.field2

Third :
Update C set C.field1 = D.field1 from tblhelptable D
join tblmaintable C on D.field2 = C.field2

Fourth :
Second :
Update C set C.field1 = D.field1 from tblmaintable C
join tblhelptable D on D.field2 = C.field2


sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-08-28 : 10:58:27
Identical. http://www.youtube.com/watch?v=i2nuPVTU4Z4
Go to Top of Page

learning_grsql
Posting Yak Master

230 Posts

Posted - 2012-08-28 : 11:04:15
@sunitabeck.....thanks but i don't find any information related sql in your link.

so you mean it can be used alternatively?
Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-08-28 : 11:10:36
quote:
Originally posted by learning_grsql

@sunitabeck.....thanks but i don't find any information related sql in your link.

so you mean it can be used alternatively?

Sorry, I was trying to be funny, but guess not. That link is really a link to scene from the movie "My Cousin Vinny".

Yes, the four updates are identical. Should be logically and physically be identical as far as I know.
Go to Top of Page

learning_grsql
Posting Yak Master

230 Posts

Posted - 2012-08-28 : 13:29:30
Oh sorry then. I'm not so good in English so I could not understand what you were trying to do and I thought by mistake you posted incorrect link....BTW: Many thanks for your useful replies in many threads..
Go to Top of Page
   

- Advertisement -