日期:2014-05-18  浏览次数:20743 次

求oracle 多表update方法
t1
-----------------------
id         A             B             C

t2
---------------------
id         F

如果满足条件:t1.id   =   t2.id   ,     t1.B   =   '0 ',   F   =   null
就把F的值设置为C
请问如何实现   ?



------解决方案--------------------
update t2 set t2.XX= 'F ' from t1,f2 where t1.id = t2.id and t1.B = '0 ' and F = null

------解决方案--------------------
我来帮顶来了!!!!!
------解决方案--------------------
update t2 set t2.F= 'C ' from t1,f2 where t1.id = t2.id and t1.B = '0 ' and F IS null 才行; Null是不能用‘=’的
------解决方案--------------------
update t2 set t2.F=(select t1.C from t1 where t1.id = t2.id and t1.B = '0 ' and t2.F IS null )
------解决方案--------------------
试试上面的sql应该可以的
------解决方案--------------------
没反应?

------解决方案--------------------
~~路过~帮顶~~
------解决方案--------------------
ding
------解决方案--------------------
~~路过~帮顶~~

------解决方案--------------------
update t2 b
set b.f =
(select a.c from t1 a
where a.id = b.id and b.b <> 0 and a.f is null
)