怎么样在两个表中进行计算,A表中的一个字段的一个整数值减去B表中的一个字段的一个整数值结果保存在B表中

解决方案 »

  1.   

    update B set B.fieldB=(Select a.fieldint from a where a.id=b.id) - B.fieldA
      

  2.   

    update b 
    set field1 = cast(a.fielda as integer) - cast (b.fieldb as integer)
    from a
    where ....
      

  3.   

    update b set field1 = field1 - a.field1
    from a
    where ur condition
      

  4.   

    这也要别人写清楚?楼主太懒点了!
    procedure tform1.button1click(...)
    begin
    with query1 do
    begin
    close;
    sql.clear;
    sql.add('update b set field1 = cast(a.fielda as integer) - cast (b.fieldb as integer) from a where ....');
    execsql;
    end;