Up¬¬¬¬

解决方案 »

  1.   

    Update B
    set B.P1 = A.P1,
        B.P2 = A.P2
    from A,B
    Where B.p in (select p from A)
      

  2.   

    Update B
    set B.P1 = A.P1,
        B.P2 = A.P2
    Where B.p in (select p from A)
      

  3.   

    看一看我原来的一程序吧,不是用一条SQL 语句可以解决的,用DELPPHI写一个循环吧,如果记录的话,可能要好多分钟:
      screen.Cursor:= crSqlWait;
      with adoquery2 do//adoquery2对应于你的表A
      begin
        close;
        sql.Clear;
        sql.add('select hykh from customer order by hykh');
    //hykh(会员卡号)相当于你的关键字P
        open;
        prior;
        while not eof do
        begin
          hykh:=  trim(fieldbyname('hykh').AsString);
          adoquery3.Close;//ADOQUERY3相当于你的表B
          adoquery3.SQL.clear;
          adoquery3.SQL.Add('select hykh from MemberOrdersView where hykh=:hykh group by hykh,[name],job,hyjb,zmdname');
          adoquery3.Parameters.ParamByName('hykh').Value:=  hykh;
          adoquery3.open;
          next;
        end;
      screen.Cursor:= crdefault;
      

  4.   

    update b set b.p1=a.p1, b.p2=a.p2 where a.p=b.p
      

  5.   

    UPDATE B 
    SET
      B.P1=A.P1,
      B.P2=A.P2
    from A,B
    WHERE B.P IN (SELECT P FROM A )
      

  6.   

    UPDATE B 
    SET
      B.P1=A.P1,
      B.P2=A.P2
    from B,A 
    WHERE B.P=A.P
      

  7.   

    update b set b.p1=a.p1, b.p2=a.p2 where a.p=b.p
      

  8.   

    TO: manboo(折翼天使在红叶飞舞)
    有分有分,就是还没解决呀TO : Drate(小虫) 
      这样慢了点吧,要是能用一句SQL实现,那就好了TO:CloneCenter(复制中心) 
    我也这样试过但是不行呀,你的通过了吗?TO:breezing(网上的小鱼), delphi_han(呵呵) 
    你们那样子我都试过但是还是行不通呀.噢,忘了告诉大家了,我用的数据库是ACCESS
    如果分不够我还可以加的,只是我一次最多只可以给100分呀
      

  9.   

    update b set b.p1=a.p1,b.p2=a.p2 from b,a where a.p=b.p
      

  10.   

    update b set b.p1=(select a.p1 from a where b.p=a.p),b.p2=
    (select a.p2 from a where b.p=a.p)
      

  11.   

    错了,应该是
    update b set b.p1=(select a.p1 from a where a.p=b.p),b.p2=
    (select a.p2 from a where a.p=b.p)
      

  12.   

    to:m_leaner(追鑫) 
    但是还是出错呀,错误提示:操作必需是一个可更新的查询
      

  13.   

    我建议你用LEFT JOIN ON!
      

  14.   

    update b  set 
       b.p1=(select a.p1 from a where a.p=b.p),
       b.p2=(select a.p2 from a where a.p=b.p)这样绝对没有问题
      

  15.   

    你是用什么数据库的?如果用Access可以创建一个查询:query1
    select * from a inner join b on (a.p=b.p)然后执行
    update query1
    set b.p1=a.p1,b.p2=a.p2
    即可