[英]Updating Values of a Column from one Table to another
I have two tables:-我有两张桌子:-
Source Table: ACT_DT
with columns ( CUST_NAME, ACC_TYPE, CUST_STAT, SB_ACT_DT
);源表:
ACT_DT
列( CUST_NAME, ACC_TYPE, CUST_STAT, SB_ACT_DT
);
Target Table: ORG_DT
with columns ( CUST_NAME, ACC_TYPE, CUST_STAT, SB_ACT_DT
);目标表:
ORG_DT
与列( CUST_NAME, ACC_TYPE, CUST_STAT, SB_ACT_DT
);
The column SB_ACT_DT
in the Target table has all null values.目标表中的
SB_ACT_DT
列全为空值。 I need to update that column with the values of same column as in source table.我需要使用与源表中相同列的值更新该列。 The condition to be checked are:
要检查的条件是:
ACC_TYPE='Billing' and CUST_STAT='Active'.
The Target table has to be updated only if the above conditions are found true.只有在发现上述条件为真时才必须更新目标表。
How can I do it?我该怎么做? Your help is appreciated.
感谢您的帮助。
What you are looking for is Update table using Join您正在寻找的是使用 Join 更新表
UPDATE ORG_DT o
JOIN ACT_DT a
ON o.CUST_NAME=a.CUST_NAME
AND
o.ACC_TYPE=a.ACC_TYPE
AND
o.CUST_STAT=a.CUST_STAT
SET o.SB_ACT_DT = a.SB_ACT_DT
WHERE a.ACC_TYPE='Billing' AND a.CUST_STAT='Active'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.