update t2 set t2.kbn='0' where t2.kbn='1' and exists(select 1 from t1 where t2.键=t1.键);

解决方案 »

  1.   

    大哥,你好快啊,不过我还有一个问题。
    如果要是更新两个字段呢。
    比如说,KBN1和KBN2(同一记录里面的字段)。
    当然逻辑不变,还是为1的时候变0。
      

  2.   

    update t2 set t2.kbn1='0' ,t2.kbn1='0' ...:)
      

  3.   

    update t2 set t2.kbn1=0 ,t2.kbn1=0 where t2.kbn1=1 and t2.kbn2=1 and exists(select 1 from t1 where t2.键=t1.键);
      

  4.   

    update t2 set t2.kbn1=decode(t2.kbn1,1,0,t2.kbn1),
                  t2.kbn2=decode(t2.kbn2,1,0,t2.kbn2) 
    where (t2.kbn1=1 or t2.kbn2=1) and exists(select 1 from t1 where t2.键=t1.键);
      

  5.   

    刚才的状况是这样,我用sql-plus查询的时候,查询不到变更前的记录。
    但是我用access通过odbc查看表的时候,看到的仍然是以前的记录。
    ORARichard(没钱的日子......) 大哥的语句是没有问题的,可能是延迟的问题。
    但是access显示的数据更新延迟了5分钟,请问为何access不能同步显示oracle数据表数据的变化呢?
    请知道的朋友大概齐说说可以么?
      

  6.   

    执行完操作后,在SQLPLUS中
    commit;
      

  7.   

    大哥,你在我心目中已经接近于神了。
    我刚才又测了一遍,数据完全正确。
    你能再解释一下select 1 from t1 where t2.键=t1.键,这句的意思么?那么select后面的1起个什么作用呢?
    得到你的回答马上结帖。
      

  8.   

    select 1 from t1 where t2.键=t1.键
    这句本身没什么特别的意思,
    关键是放在EXISTS后面表示t1,t2中是否存在t2.键=t1.键的记录