表A 表B
表A.bm = 表B.bm
现在要更新 表 A.zt = '1' 条件是 where 表A.bm = 表B.bm and 表A.zt='0' and 表B.cd='1'
我写的语句是 update (select * from A,B where A.bm=B.bm and A.zt='0' and B.cd='1') set zt = '1'
结果报错
ORA-01779 : cannot modify a column which maps to a non key-preserved talbe
------解决方案--------------------
- SQL code
update a set zt='1'where exists(select 1 from A,B where A.bm=B.bm and A.zt='0' and B.cd='1')
------解决方案--------------------
- SQL code
--修改下update a set zt='1'where exists(select 1 from B where A.bm=B.bm and A.zt='0' and B.cd='1')
------解决方案--------------------
- SQL code
update A set zt = '1'where A.zt='0' and exists (select * from B where A.bm=B.bm and B.cd='1')
------解决方案--------------------
打慢了点……
------解决方案--------------------
- SQL code
update a set zt='1'where exists(select 1 from B where A.bm=B.bm and A.zt='0' and B.cd='1')