D7 ADO Acess数据库 有表1和表2,字段都是数字,表2为空表,表2的d1字段由表1的2个字段相减得到,运行报“参数 表1.h2没有默认值”
    with ADOQuery1 do
    begin
      close;
      sql.clear;
      sql.add('update 表2 set d1 = 表1.h2 - 表1.h1 where 表1.xh>=2012001');
      execsql;
    end;
第一次弄数据库。

解决方案 »

  1.   

    sql.add('update 表2 set d1 = 表1.h2-表1.h1 from 表1 where xh>=2012001');
    报错:
    操作符丢失'表1.h2-表1.h1 from 表1'?????
      

  2.   

    sql.add('update 表2 set d1 = 表1.h2 - 表1.h1 where 表1.xh>=''2012001''');
      

  3.   

    你這個問題比較大.
    1.表2是空的,你修改什麼?應該是插入一條記錄。可以是:insert 表2(d1) select h2-h1 from 表1 where xh>='2012001'
    2.如表2不是空的,要修改,那你的語句也錯了.更改為:update 表2 set d1=(select h2-h1 from 表1 where xh>='2012001')
    另外你的表結構不知,關鍵字等都沒說明。
      

  4.   

    sql.add('update 表2,表1 set 表2.d1 = 表1.h2-表1.h1 where 表1.xh>=''2012001''');