网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > 数据库 > Oracle教程
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket
数据库:数据库教程,数据库技巧,Oracle教程,MySQL教程,Sybase教程,Access教程,DB2教程,数据库安全,数据库文摘
本月文章推荐
.VC下利用Pro*C开发Oracle接口.
.Brian Peasland:充分认识和利用O.
.如何让Oracle数据库始终保持优良.
.oracle系统紧急故障处理.
.解析:用UNIX的kill命令终止Orac.
.Linux之菜鸟日记(三).
.Installing Oracle9i Database o.
.10gRAC系列之10gRAC的网络设置.
.研究生管理信息系统的开发流程一.
.在RedHat7.0下Oracle8.1.6的安装.
.教你检测Oracle的可用性和表空间.
.Oracle回滚表空间数据文件误删除.
.Oracle RMAN快速入门指南的具体介.
.Oracle SQL 基础.
.ORACLE中LOB字段的使用和维护.
.做Oracle DBA要会些什么问题.
.excel文件的导入-oracle.
.ORACLE在HP-UX下的系列问题处理(.
.调整缓冲区高速缓存(Buffer Cach.
.UNIX和WINDOWS2000上的ORACLE的差.

oracle update多表关联

发表日期:2008-2-9


UPDATE A.A3 = A.A3+B.B3 的问题 表A 结构 : A1 , A2 ,A3
表B 结构: B1,  B2,  B3
其中 A1 ,B1 为PK ,切值相同 就是可以使用A1 = B1 了. 请问用SQL 语句或过程该如何实现如下的功能??? 更新A 表的 A3 ,用A.A3 与B.B3之和更新. 3>update A
set A3 = (select A.A3 + B.B3 from B where A.A1 = B.B1) ; 7>update (select a1,a3,b1,b3 from a,b where a1=b1) set a3=a3+b3
开执行计划, 谈论效率是没有太多的意义的^_^..
三楼的写法与7楼的写法得到的结果是不同的. 三楼的写法会更新所有记录, 而7楼的写法只修改两者相交的相关记录信息. 7楼的写法可以更加轻易的控制这条update语句的执行计划, 不过要求B表必须在对应的字段上有主键索引:) , 在B表在对应字段上有主键索引的时候, 建议使用7楼的写法. 可以参考一下这个帖子^_^ http://www.cnoug.org/viewthread.php?tid=44070
(测试没有成功..不知道怎么搞的.)
参考了下面的:
非常佩服。抱着学习的态度,重写了一下三楼的,在没有主键的情况,请指教:
update a
set a3=(select a3+b3 from b where a1=b1)
where a1=(select b1 from b where a1=b1)
如下:
update con_eme_on20050309 a set a.con_price=(select a.con_price+(b.annuity-a.annuity)+(b.nojob-a.nojob)+(b.medicare-a.medicare)+(b.birthfee-a.birthfee)+(b.bruisefee-a.bruisefee) from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base),a.emp_base=(select b.emp_base from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base),a.annuity=(select b.annuity from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base),a.nojob=(select b.nojob from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base),a.medicare=(select b.medicare from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base),a.birthfee=(select b.birthfee from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base),a.bruisefee=(select b.bruisefee from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base),a.nojobbase=(select b.nojobbase from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base),a.mediabase=(select b.mediabase from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base),a.birthbase=(select b.birthbase from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base),a.bruisebase=(select b.bruisebase from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base)
where a.emp_cod in(select b.emp_cod from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base)
公积金:
update con_eme_on20050309 a set a.con_price=(select a.con_price+(b.accumulation-a.accumulation) from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base),a.accumulation=(select b.accumulation from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base),a.accumulationbase=(select b.accumulationbase from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base),a.accumulationbase1=(select b.accumulationbase1 from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base)

where a.emp_cod in(select b.emp_cod from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base)

上一篇:简便实现Oracle数据库文件移动方法 人气:653
下一篇:看看葫芦里的药 ORACLE性能调优原则 人气:590
浏览全部Oracle教程的内容 Dreamweaver插件下载 网页广告代码 祝你圣诞节快乐 2009年新年快乐