|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Update ... from ...
Hello.
I am a little lost... in the use of update ... from ... Let us assume I have something like this: UPDATE parts SET id_geometry = b.id_geometry_duplicate FROM parts a INNER JOIN fn_duplicate_parts(@id_project) b ON a.id_part = b.id_part_org How does this query know which rows it needs to update? I can see no relationsship between the tables parts and b (which by accident is also parts). I only want to update those rows in parts where id_part is in b(as id_part_org). I guess it is my lack of knowledge, but really I cannot see the logic in this. Could anyone clarify? Thanks in advance, Lasse Johansen |
|
#2
|
|||
|
|||
|
when you say inner join it's kind of like making it one table on the ON part, so if your tables are
Code:
A circle 12 square 13 rhombus 9 B square 15 rhombus 15 BlackSabbath 666 the inner join on makes them equal on id, in this case lets say id is the circle, square rhombus name portion so our table after the inner join is this Code:
A.square A.12 B.square B.15 A.rhombus A.13 B.rhombus B.15 and you're setting A. price equal to B.price, so it turns into Code:
square 15 square 15 rhombus 15 rhombus 15 so your final A table is Code:
A circle 12 square 15 rhombus 15 |
|
#3
|
|||
|
|||
|
Actually this is not my concern... My concern is how can parts a(in FROM(SELECT) clause) refer to parts(in UPDATE clause)
|
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > Update ... from ... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|