我想用一年的条件将数据从一个表更新到另一个表。
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'
此处dcamt
pgptrans
ecamt
表pgptans060713
的{{1}}更新empcode
{{1}}(年份应为201308年),{{1}}从130开始
请帮帮我
提前thanx
舒卜哈
答案 0 :(得分: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'
答案 1 :(得分: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