Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Update with a JOIN

$
0
0
In the last weeks I came to work with SQL Server more closely and - not being used to it - I stumbled over the sematics of an UPDATE statement using a JOIN (something which is not available in e.g. Oracle).

I wonder what the difference between these two updates is:

Code:

update foo
  set ..
from bar
  where bar.fid = foo.id;

and
Code:

update foo
  set ...
from foo f1
  join bar on bar.fid = f1.id;

In both cases I have an inner join between foo and bar, but in the second one, foo is actually listed twice in the update statement.

As far as I can tell, both carry out the same thing - at least with my test data.

So my question is: is there a difference between the two, and if yes, what exactly is the difference?

Viewing all articles
Browse latest Browse all 13329

Trending Articles