您的位置:首页 > 数据库 > Oracle

oracle通过两张表的一个字段对应,update其中一张表的某个字段

2013-07-17 15:26 330 查看
A、B两张表,通过关联字段A1=B1,复制B表字段B2中数据到A表A2中

update A a set a.A2 = (select b.B2 from B b where b.B1=a.A1) where
exists (select 1 from B where B.B1=a.A1)


写成如下

update A a set a.A2 = (select b.B2 from B b, A c where b.B1=c.A1) where
exists (select 1 from B where B.B1=a.A1)
则是从两个表交叉集合取值,错误结果

参考自http://www.2cto.com/database/201304/202364.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  oracle
相关文章推荐