update user.a set user.b.value=user.a.id where user.B.COL1=user.A.COL1 and user.B.COL2=user.A.COL2user换成你的数据库的用户名。

解决方案 »

  1.   

    UPDATE B
    SET B.Value = A.ID
    FROM B INNER JOIN A ON (A.COL1 = B.COL1 AND A.COL2 = B.COL2)
    GO
    应该还有其他方法
      

  2.   

    update b set
     b.value = (select a.id from a
                where a.col1=b.col1 and a.col2=b.col2)
      

  3.   

    update b set b.value = (select a.id from a where a.col1=b.col1 and a.col2=b.col2);
    要确保B.COL1=A.COL1 and B.COL2=A.COL2条件限制后能返回唯一值
      

  4.   

    update user.a set user.b.value=user.a.id where user.B.COL1=user.A.COL1 and user.B.COL2=user.A.COL2数据库提示B.COL2(有时提示B.COL1)不是合法的列.
    WHERE部分我用在select中是行的,不会是误打错列名。UPDATE B
    SET B.Value = A.ID
    FROM B INNER JOIN A ON (A.COL1 = B.COL1 AND A.COL2 = B.COL2)数据库提示SQL语句不正常结束---不是分号问题,加不加都会提示错误。
    为什么这样?以上两种写法是可行的吧?
      

  5.   

    update b set b.value = (select a.id from a where a.col1=b.col1 and a.col2=b.col2)比较好一些
      

  6.   

    update b 
    set b.value = (select a.id from a where a.col1=b.col1 and a.col2=b.col2)
    select 要返回多行就会出错  set 后必须要等于一个单值最好用PL/SQLdeclare
        cursor UB is select a.id as id, b.rowid as row_id 
                     from a, b where a.col1=b.col1 and a.col2=b.col2;
    begin
        for tab in UB loop
           update b       
           set value=tab.id
           where rowid=tab.row_id; 
        end loop;
    end;
      

  7.   

    同意  space6212327() 大哥做的
      

  8.   

    to  zzwind5() :I agree