http://community.csdn.net/Expert/topic/3336/3336852.xml?temp=.4589197update 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); -- orupdate t1 set t1.col1=
nvl(
(select t2.col1 from t2 where t1.col3=t2.col3 and t2.col2<>t1.col2 )
,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); -- orupdate t1 set t1.col1=
nvl(
(select t2.col1 from t2 where t1.col3=t2.col3 and t2.col2<>t1.col2 )
,t1.col1
)
解决方案 »
- VS 2008 在同一台机子上连接oracle9i的数据库时,oracle9i要同时装上服务器和客户端?还是只装服务器就够了啊?
- oracle varchar2(45)只能插入10个汉字,怎么回事?
- 如何在子cursor的where 条件中处理null的情况
- 询问一个和hibernate语句有关在oracle中使用的sql
- 导入dmp文件,遇到:IMP-00003: 遇到 ORACLE 错误 1658
- 请教Oracle和Sybase建库的速度比较,100分解决即结贴
- 触发器问题!在触发的表里更新字段
- 對於同一張表,EachRow Trigger和Statement Trigger的前後被觸發順序是什麼?望高手點撥
- 关于oracle数据库中序列的问题
- 求sql语句,谢谢!
- (+)= 该关系是否能用函数
- 有没有办法限制某个库表只允许插入一条记录呢??
update t1 set t1.col1=(SELECT t2.col1 from t2 where t1.col3=t2.col3 and t2.col2<>t1.col2 ) --这样就够啊。。
(select t2.col1 from t2 where t1.col3=t2.col3 and t2.col2<>t1.col2 ),t1.col1)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);
这样写法是错误的,会更新整个表,正确的写法
update t1 set t1.col1=(SELECT t2.col1 from t1) where t1.col3=t2.col3 and t2.col2<>t1.col2 )