SELECT B_ID, B_NAME, NVL(A_PRICE, B_PRICE) FROM A, B WHERE B.B_ID = A.A_ID(+)
update b set b.b_price = (select a.a_price from a where a.a_id=b.b_id)
sorry,没看到你的需求是update, #2++
-- 加一个 exists 条件,不然找不到记录时,就更新成 NULL 了。 -- PS : update 语句是拷的 2# 这个兄弟的update b set b.b_price = (select a.a_price from a where a.a_id=b.b_id) where exists(select * from a where a.a_id=b.b_id)
update b set b.b_price = (select a.a_price from a where a.a_id=b.b_id) where exists(select * from a where a.a_id=b.b_id) 这个也是不行啊。报orac-01407 的错
检查一下你的 a 表,看看 a_price 是不是 null 值;
再加个条件过滤下就是了 update b set b.b_price = (select a.a_price from a where a.a_id=b.b_id) where exists(select * from a where a.a_id=b.b_id and a.a_price is not null)
FROM A, B
WHERE B.B_ID = A.A_ID(+)
-- 加一个 exists 条件,不然找不到记录时,就更新成 NULL 了。
-- PS : update 语句是拷的 2# 这个兄弟的update b set b.b_price = (select a.a_price from a where a.a_id=b.b_id)
where exists(select * from a where a.a_id=b.b_id)
where exists(select * from a where a.a_id=b.b_id)
这个也是不行啊。报orac-01407 的错
检查一下你的 a 表,看看 a_price 是不是 null 值;
update b set b.b_price = (select a.a_price from a where a.a_id=b.b_id)
where exists(select * from a where a.a_id=b.b_id and a.a_price is not null)