兩張表對應關系為:父表的Fid對應子表的parentid,且為一對多關系,一個Fid對應多個parentid,如何根據這個對應關系來把父表的M欄位值update到子表的fm值中
update 子表 set fm=
(select a.M from 父表 a inner join 子表 b on b.fm=a.M) where fm is null
會提示ORA-01427單行子查詢回傳多個行,加上rownum =1后不報錯,但是子表的fm值仍舊是空值,沒有被更新。請大家指教一下!
uj5u.com熱心網友回復:
update zi t1 set t1.fm = (select v1.m from fu v1 where t1.parentid = v1.fid)uj5u.com熱心網友回復:
update 子表 a fm=(select m from 父表 b where a.parentid=b.fid and rownum<2)where a.parentid in (select fid from 父表)
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/19588.html
標籤:基礎和管理
