我有两张桌子:
t1
列A, B, X, Y, Z
和t2
列A, B, N
我想将t1.A
设置为值t2.N
t1.A = t2.A and t1.B = T2.B
。
听起来很简单,但我不知道要解决这个问题;我试过像:
update t1 set A = (select t2.N
from t1,t2
where t1.A = t2.A
and t1.B = t2.B)
......
但这会产生错误:
ERROR: You cannot reopen t1.DATA for update access with member-level control because t1.DATA .....
有什么想法吗?
答案 0 :(得分:1)
我怀疑你只想要一个相关的子查询:
update t1
set A = (select t2.N
from t2
where t1.A = t2.A and t1.B = t2.B
);
注意:您应该小心子查询只返回一行。
答案 1 :(得分:0)
除语法错误之外的旁注:你得到ERROR: You cannot open WORK.T1.DATA for output access with member-level control because WORK.T1.DATA is in use by you in resource environment DATASTEP.
,因为你的输出数据集仍在窗口中打开。在重新运行之前关闭VIEWTABLE:Work.T1
。