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.
Author |
Topic |
ctvogds
Starting Member
6 Posts |
Posted - 2005-05-16 : 18:26:42
|
Can anyone explain exactly how I am to interpret the following statement? I have had trouble finding documentation online for this particular example. It consists of an Inner Join nested within an Update statement.UPDATE USER_FSV AS A INNER JOIN CALC_3_LE_M AS B ON A.familyid=B.familyid SET A.leevm3s=B.leevm3s, A.lenim3s=B.lenim3s;So the query is doing what I want it to, I just am not sure I fully understand it. I pretty much just need to pull the two fields from table CALC_3_LE_M and put them into the USER_FSV table wherever the id's from each table match. Note that every id in the CALC_C_LE_M table is already in the USER_FSV table.A logical way to show exactly what I mean here would be something like this, even though this is invalid Access SQL syntax its easy to see exactly what this query would do if it were valid.UPDATE USER_FSV SETUSER_FSV.leevm3s=CALC_3_LE_M.leevm3s, USER_FSV.lenim3s=CALC_3_LE_M.lenim3sWHERE USER_FSV.familyid=CALC_3_LE_M.familyid;Any help anyone might have to offer would be appreciated! Thanks! |
|
SMerrill
Posting Yak Master
206 Posts |
Posted - 2005-08-10 : 21:12:25
|
Your concept of how this works is exactly correct.The "INNER JOIN (...tablenames...) ON A.familyid=B.familyid" construct is the matching part.The "UPDATE ... SET This1=That1, This2=That2" construct is the replacing part.The "USER_FSV AS A", and "CALC_3_LE_M AS B" is an alias or a short-hand that uses the nicknames "A" and "B" for the full table names within the query.~ Shaun MerrillSeattle, WA |
 |
|
|
|
|