ORACLE UPDATE 具有多个值的多行
ORACLE UPDATE multiple rows with multiple values
select distinct T1.a1, T2.a1
from T1, T2, T3 where
T2.name='Something' and T2.value is not null and
T2.a1=T3.a1 and T1.a2=T3.a2 and
T1.a3='Something' and T1.a4 is null
我在 T2 中填充了值,在 T1 中缺失了这些值。
我必须用 T2 值更新 T1 值。 SELECT sql 正确地带来了价值。但是我无法为 ORACLE 数据库提供 UPDATE sql。
尝试合并:
merge into t1 tgt
using (select distinct t1.a1 t1_a1, t2.a1 t2_a1
from t1,
t2,
t3
where t2.name='Something'
and t2.value is not null
and t2.a1=t3.a1
and t1.a2=t3.a2
and t1.a3='Something'
and t1.a4 is null) src
on (tgt.a1 = src.t1_a1)
when matched then
update set tgt.a1 = src.t2_a1;
select distinct T1.a1, T2.a1
from T1, T2, T3 where
T2.name='Something' and T2.value is not null and
T2.a1=T3.a1 and T1.a2=T3.a2 and
T1.a3='Something' and T1.a4 is null
我在 T2 中填充了值,在 T1 中缺失了这些值。
我必须用 T2 值更新 T1 值。 SELECT sql 正确地带来了价值。但是我无法为 ORACLE 数据库提供 UPDATE sql。
尝试合并:
merge into t1 tgt
using (select distinct t1.a1 t1_a1, t2.a1 t2_a1
from t1,
t2,
t3
where t2.name='Something'
and t2.value is not null
and t2.a1=t3.a1
and t1.a2=t3.a2
and t1.a3='Something'
and t1.a4 is null) src
on (tgt.a1 = src.t1_a1)
when matched then
update set tgt.a1 = src.t2_a1;