update cp_kpi_info_fy t4 set t4.resperson = (select t5.account from security_ultra_user t5, tb_tmp_wei t6 where t6.name = t5.account and t4.capescode = t6.code)
解决方案 »
- 求解!1条语句分10部分查询!
- oracle11G 有对应的客户端吗?有的话给出下载网址!
- PL/SQL 打Tables 报错 ora-00911
- 不带精度的NUMBER类型究竟能存多少位长度的数据?
- 七夕散分
- 请教commit难道不相当于“执行(F8)”吗?
- 哪有oracle的好的教程下载?
- 将数据库设置为SUSPEND模式,为恢复直接断开连接,再次连接不上,该如何解决?
- 计算1+2+3+...+100=?并显示从第10行第10列起显示其结果。急急!!!
- oracle:sql如何取出多条时间区间在每隔30分钟拼接好
- oracle tuxedo tpopen()的问题
- oracle9i 中关于 regexp_substr
UPDATE cp_kpi_info_fy t4
SET t4.resperson =
(SELECT t5.ACCOUNT
FROM security_ultra_user t5, tb_tmp_wei t6
WHERE t6.NAME = t5.user_name AND t4.capescode = t6.code and rownum<=1)
WHERE t4.capescode IN (SELECT t6.code
FROM security_ultra_user t5, tb_tmp_wei t6
WHERE t6.NAME = t5.user_name)
(select t5.account from security_ultra_user t5, tb_tmp_wei t6 where t6.name = t5.account and t4.capescode = t6.code)
例如t4.capescode=1那么t6.code=1的情况下,t6.name有多个,导致返回了多个account。
这两个where的用处不同,第一个用于select,是要找出对应的ACCOUNT.第二个用于update,说明只有这些数据要更新,如果不加后面这个where,就会把所有数据都更新一次,在select中没有找到值的就会被更新为null
rownum<1 这句有什么用呢?按理说t4和t6没有重复指标,不应该返回很多行相同的吧?
rownum<1是让Oracle不报"single-row subquery returns more than one row",因为Oracle怀疑这句select会找出多行,仅仅是怀疑而已.用rownum<=1就是告诉Oracle,这里只有一条记录.