oracle多表关联多字段update

分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow

也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!

                       

多表关联多字段update

有代码有J8:

update spatial_referencesset(auth_name, auth_srid, falsex, falsey, xyunits, falsez, zunits, falsem, munits, xycluster_tol, zcluster_tol, mcluster_tol, object_flags, srtext)=(select  auth_name, auth_srid, falsex, falsey, xyunits, falsez, zunits, falsem, munits, xycluster_tol, zcluster_tol, mcluster_tol, object_flags, srtextfrom spatial_references where srid=0)where srid=2;
   
   
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33

===============================================
2016.07.09
以上这条语句不够实用。今天有同事问到,结果露怯,于是发粪涂墙,狂搜资料,又写了一条实用一点的:

update qq q set 证书GUID=(select zs.guid from 证书表 zs where zs.code=q.证书编号 and rownum=1)
   
   
  • 1

更完整一点的:

update qq q set 证书GUID=(select zs.guid from 证书表 zs where zs.code=q.证书编号 and rownum=1)where exists(select 1 from 证书表 zs where zs.code=q.证书编号 and zs.guid<>q.证书GUID)
   
   
  • 1
  • 2
update nodeconfiginfo n set (qh_name,qh_parentid,qh_orderid)=(select qh_name,qh_parentid,qh_orderidfrom SeaBoardConfig s where s.qh_id=n.qh_id)where exists(select 1 from SeaBoardConfig s where s.qh_id=n.qh_id);
   
   
  • 1
  • 2
  • 3

这条语句,SET里有个循环;然后外层也有个循环。这两个循环没有什么直接关系。我不知道这条SQL语句是如何执行的,猜想应该是嵌套循环:

foreach(){//外层循环    foreach()    {//set循环    }}
   
   
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

如果没有外层循环的话,那么会全表执行。

           

扫描二维码关注公众号,回复: 4988701 查看本文章

给我老师的人工智能教程打call!http://blog.csdn.net/jiangjunshow

这里写图片描述

猜你喜欢

转载自blog.csdn.net/hddfuuh/article/details/84099813
今日推荐