update t1 set t1.col1=(select t2.col1 from t2 where t1.col3=t2.col3 and t2.col2<>t1.col2 )
解决方案 »
- 求助 先 where条件过滤 还是先 join on
- 【求ORACLE版本下载】
- 从未见之怪现象 select sysdate from dual 带不带服务名连接 结果不一致
- JOB 的问题,肯请大家来帮帮我
- 请教如何在开发的客户端程序中创建Oracle服务名
- 如何将SQL Server 中的数据库移植到Oracle数据库中?谢谢!
- 关于decode ,高手进
- oralce 从2亿条记录中按条件统计出相关记录的合计--怎样写Sql语句--是否有特殊方法
- UTL_FILE求救
- oracle 对象类型 自定义构造函数报错
- 关于DBMS_SQL封装过程的语句转换
- oracle8.05 一存储过程语句错误,怎么从备份语句中单独恢复这一个存储过程,在线等待
update t1 set t1.col1=(
select t2.col1 from t2
where t1.col3=t2.col3 and t2.col2<>t1.col2 )
where exists (select 1 from t2
where t1.col3=t2.col3 and t2.col2<>t1.col2);
用得着where exists (select 1 from t2
where t1.col3=t2.col3 and t2.col2<>t1.col2); ??????
update t1 set t1.col1=
nvl(
(select t2.col1 from t2 where t1.col3=t2.col3 and t2.col2<>t1.col2 )
,t1.col1
)
SQL SERVER里没问题,但ORACLE好象不支持。
---------------------------------------------------------在sql server中,上述例子可以执行通过,原因是t2.col1 虽然可能返回多个值,
但是sql server默认取最后一个值为当前值,所以可以执行通过,不会报错!
但是在oracle中,语法要求比较严格,t2.col1 可以得到多个值,oracle就无从
知道,应该把哪个值赋给t1.col1,所以,无法执行。
update t1 set t1.col1=(select t2.col1 from t2 where t1.col3=t2.col3 and t2.col2<>t1.col2 )