udpate a set DJ00=(select DJ00 from b where a.SP00=b.SP00) 
where 
a.SP00 exists (select SP00 from b where a.SP00=b.SP00);

解决方案 »

  1.   

    udpate a set DJ00=(select max(DJ00) from b where a.SP00=b.SP00) 
    where exists (select 1 from b where a.SP00=b.SP00);
      

  2.   

    update 表A a set a.DJ00=(select b.DJ00 from 表B b where a.SP00=b.SP00);
      

  3.   

    俺的语句是B表中的BOOK1必须是唯一的,
    如果不是唯一的
    那么要取其中一个值
    如果值任意取,可以这样
    update 表A a set a.DJ00=(select MAX(b.DJ00) from 表B b where a.SP00=b.SP00 group by b.SP00);
      

  4.   

    如果表b的DJ00有唯一约束,则ATGC的法子才管用。
      

  5.   

    好像楼上的所有语句都要球在B表上有唯一约束吧,要不a.DJ00=(select b.DJ00 from 表B b where a.SP00=b.SP00);可以执行吗?学习
      

  6.   

    俺这个可以,因为俺求了max,即使不是唯一,也变成唯一了,只要楼主对DJ00值没有要求
    俺昨天也碰到这样的提问。。
      

  7.   

    update a set a.DJ00=(select MAX(b.DJ00) from b where a.SP00=b.SP00 group by b.SP00);
      

  8.   

    建立游标来做!
    DECLEAR 
    TDJOO  B.DJOO%TYPE;
    TSP00  B.SP00%TYPE;DECLARE CURSOR TEMP_LIST IS 
       SELECT B.DJ00,B.SP00 FROM A ,B 
           WHERE A.SP00=B.SP00 ;BEGINOPEN TEMP_LIST;
    LOOP
        FETCH TEMP_LIST INTO 
               TDJOO,
               TSP00;     EXIT WHEN TEMP_LIST%NOTFOUND;        UPDATE A SET 
                   A.DJOO=TDJOO
             WHERE A.SP00=TSP00;      COMMIT;EDN LOOP;
    CLOSE TEMP_LIST;
    END;
      

  9.   

    udpate a set DJ00=(select max(DJ00) from b where a.SP00=b.SP00) 
    where exists (select 1 from b where a.SP00=b.SP00);
      

  10.   

    同意zmgowin(隐者(龙祖宗)) and  bzszp(SongZip)
      

  11.   

    to bzszp(SongZip)
    这样的问题你已得了很多分分了吧。呵呵,我也是其中之一啊。to 楼主
    同意bzszp(SongZip)to 隐者(龙祖宗))
    你在exists前,where后加上的a.sp00是做什么用的,这条语句能执行吗?还是误加上的。