oracle update 多个字段,能不能 只要此中一个字段有值 这条记录就不更新
oracle update 多个字段,能不能 只要其中一个字段有值 这条记录就不更新
oracle update 多个字段,能不能 只要其中一个字段有值 这条记录就不更新。
比如 :
update table_a
set (a, b, c ,d, e ,f ,g)
= ( select a, b, c ,d, e ,f ,g from table_b )
正常table_a中的 table_b中没有的记录会被置空, 如果那些记录有值的不想被置空怎么办?
------解决思路----------------------
加个nvl或者decode函数就行了
如:
update ta set a=(select nvl(tb.a,ta.a) from tb);
------解决思路----------------------
oracle update 多个字段,能不能 只要其中一个字段有值 这条记录就不更新。
比如 :
update table_a
set (a, b, c ,d, e ,f ,g)
= ( select a, b, c ,d, e ,f ,g from table_b )
正常table_a中的 table_b中没有的记录会被置空, 如果那些记录有值的不想被置空怎么办?
------解决思路----------------------
加个nvl或者decode函数就行了
如:
update ta set a=(select nvl(tb.a,ta.a) from tb);
------解决思路----------------------
update table_a A
set (a, b, c ,d, e ,f ,g)
= ( select NVL(A.a,B.a),NVL(A.b,B.b),…… from table_b B where id=A.id )
where exists (select 1 from table_b B where id=A.id)