我有两个表,想用update 把表A 的一个字段值赋值给表BA
字段
F1
F2
F3B
字段
F1
F2
F4A.F1=B.F1 and A.F2=B.F2 set F3 = F4 
具体的SQL怎么写?

解决方案 »

  1.   

    update b set b.f3 = a.f3 from a,b where a.f1 = b.f1 and a.f2 = b.f2
      

  2.   

    楼上正确, 
    完善一下
    query1.close;
    query1.sql.clear;
    query1.sql.add('update b set b.f3 = a.f3 from a,b where a.f1 = b.f1 and a.f2 = b.f2');
    query1.ExecSQL;//更新用这个,而不是查询的query1.open;
      

  3.   

    好像不是要更新一个表,而只是想把记录插入另外一张表吧,如果是的话,请用一个insert方法,写在存储过程,不就OK了!~~
      

  4.   

    update a set a.f3=b.f4
    from a,b
    where a.f1=b.f1 and a.f2=b.f2
      

  5.   

    来晚了
    ADOquery1.close;
    ADOquery1.sql.clear;
    ADOquery1.sql.add('update b set b.f3 = a.f3 from a,b where a.f1 = b.f1 and a.f2 = b.f2');
    ADOquery1.ExecSQL