【发布时间】:2017-03-11 10:55:53
【问题描述】:
我有一个更新查询如下-
udate table1 tbl_out
set column1 =
(select colValue from table1 t1, table2 t2
where table1.product_id = table2.product_id
and t1.id = tbl_out.id)
where tbl_out.column1 is null;
这很好用。但是有些列的 table1.product_id 值为 null。
所以对于这些记录 where table1.product_id = table2.product_id 条件不满足,记录没有更新。
我尝试按如下方式添加此条件 -
where (table1.product_id = table2.product_id OR table1.product_id is null)
and t1.id = tbl_out.id
但这将返回多于 1 行,以上更新语句将失败。 我知道在这种情况下可能很简单但无法弄清楚的问题。
有人可以帮我吗?
【问题讨论】:
-
那么哪个查找表在子查询中提供
colValue?table1或table2?
标签: sql oracle sql-update