2

我想将数据从一个表更新到另一个具有年份条件的表。

UPDATE pgptrans
SET dcamt1 = t2.ecamt1
FROM pgptrans t1 
INNER JOIN pgptrans060713 t2 ON t1.empcode = t2.empcode 
WHERE       
    t1.empcode LIKE '130%' 
    AND t1.yrmn = '201308' 
    AND t2.yrmn = '201207'

这里更新dcamtpgptrans(到 201307 年)从ecamtpgptans060713从年应该是 201308)empcode从 130 开始

请帮我

提前谢谢

舒巴

4

2 回答 2

2
UPDATE t1
SET t1.dcamt1 = t2.ecamt1
FROM pgptrans t1
INNER JOIN pgptrans060713 t2 ON t1.empcode = t2.empcode
WHERE t1.empcode LIKE '130%' 
    AND t1.yrmn = '201308' 
    AND t2.yrmn = '201207'
于 2013-08-06T05:27:44.487 回答
0

使用 INNER JOIN 基于另一个表更新一个表

 UPDATE t1 SET 
        t1.status = 1
 FROM   table1 t1 
        INNER JOIN table t2 
                   ON t1.Id = t2.ID
 WHERE  t2.num = 15 
于 2014-08-18T08:57:38.927 回答