数据库A中的表T1,数据库B中有表T2
T1:
ID  Score
01   55
02   48 T2:
ID  Score   Re
01   55
02   46现在我想用Update更新Re,条件是当ID相同,但Score不同时,在Re中标出'*'.这里的目的就是在ID为02的Re中标出*update B.T2 set Re ='*' where (B.T2.Score != A.T1.Score)错误为:找不到A.T1
请高手指教,急    

解决方案 »

  1.   

    首先有个基础问题,所说的库A库B,应该为用户A用户B.update B.T2 t1 
       set  Re ='*'
     where not exits(select 1 from A.T1 t2 where t1.ID = t2.ID and t1.Score = t2.Score)
      

  2.   

    update t2 c set re=
    (
    select (case when t1.score<> t2.score then '*' else '' end)  from t1,t2 where t1.id=t2.id(+)
    and c.id=t1.id)
    where exists(select 1 from t2 d where c.id=d.id)
      

  3.   

    update t2 
    set re='*' 
    where not exists(select 1 from t1 where t1.id=t2.id and t1.score<>t2.score)
      

  4.   

    不同的数据库要先建dblink
    update t2 set re='*' where exists (select 1 from t1@dblinkname  where id=t2.id and score<>t2.score)
      

  5.   

    找不到 A.T1 那要看你的用户有没有访问 A.T1 的权限语句可以参考这句,前提是你的 ID是主键update B.T2 set B.T2.re = '*' where B.T2.id in (select B.T2.id from B.T2, A.T1 where B.T2.id = A.T1.id and B.T2.score <> A.T1.score)
      

  6.   

    -- 最近写程序老出错.调下:
    update B.T2 t1 
       set Re ='*'
     where exits(select 1 from A.T1 t2 where t1.ID = t2.ID and t1.Score <> t2.Score)
      

  7.   

    -- 还错,哈哈
    update B.T2 t1 
       set Re ='*'
     where exists(select 1 from A.T1 t2 where t1.ID = t2.ID and t1.Score <> t2.Score)