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
)

解决方案 »

  1.   

    update t1 set t1.col1=(SELECT t2.col1 from t1,t2 where t1.col3=t2.col3 and  t2.col2<>t1.col2 )
      

  2.   

    zwj0712(阿张) 的From后是不是多一个表t1啊。
    update t1 set t1.col1=(SELECT t2.col1 from t2 where t1.col3=t2.col3 and  t2.col2<>t1.col2 )       --这样就够啊。。
      

  3.   

    update t1 set t1.col1=nvl(
    (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);
      

  4.   

    楼上的好多都没有考虑子查询如果没有结果将返回null值的问题,这样就导致了那些不符合条件的都更新成为了null值了。
      

  5.   

    update t1 set t1.col1=(SELECT t2.col1 from t1,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 )