![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
let's say I have a mapping table with columns A, B and C and let's say I have a data table with columns, A, B, C, D, E, F Now, what I want to do is to replace the value of C of data table(d) with value of C in mapping table(m) which is correspomding row with d.A=m.A and d.B=m.B. |
#3
| |||
| |||
|
|
Considering those issues, I used my imagination as possible as I can, then rewrited your requirement as followings. let's say I have a mapping table with columns A, B and C and let's say I have a data table with columns, A, B, C, D, E, F Now, what I want to do is to replace the value of C of data table(d) with value of C in mapping table(m) which is correspomding row with d.A=m.A and d.B=m.B. |
|
UPDATE data_table d SET C = COALESCE((SELECT m.C FROM mapping_table m WHERE m.A=d.A and m.B=d.B ) ,d.C ); or MERGE INTO data_table d USING mapping_table m ON d.A=m.A and d.B=m.B WHEN MATCHED THEN UPDATE SET C = m.C; |
![]() |
| Thread Tools | |
| Display Modes | |
| |