首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

多 表 更 新解决方案

2012-02-17 
多 表 更 新t1-----------------------idABCt2---------------------idF如果满足条件:t1.idt2.id,t1.B0

多 表 更 新
t1
-----------------------
id         A             B             C

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

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

[解决办法]
Update t2 set F=(Select C from t1 where t1.id=t2.id and t1.B = '0 ')
where F is null
[解决办法]
update t2 ta set F=(select c from t1 tb where ta.id = tb.id and tb.B = 0
and exists(select 'X ' from t2 where ta.id = id and tb.B = '0 ' and F is null));
[解决办法]
update t2 t_2
set t_2.F = 'C '
where exists (
select 1
from t1 t_1
where t_1.id = t_2.id
and t_1.B = '0 '
and t_2.F is null
);

试试看~~

热点排行