我新建了两个表(huowei,huowei1),两个表都有同样的字段,stritemname(A),lngpositionid(I),strcustomname(A),strfullname(A),dblendstockquantity(I),pricid(I),
zizoid(I),在程序里利用query写sql语句,用update方法来用一个表更新另一个表的数据,
query2.SQL.Add('update huowei');
query2.SQL.Add('set huowei.pricid=huowei1.pricid,huowei.zizoid=huowei1.zizoid');
query2.SQL.Add('where huowei.stritemname=huowei1.stritemname and huowei.lngpositionid=huowei1.lngpositionid and huowei.strcustomname=huowei1.strcustomname and huowei.strfullname=huowei1.strfullname');
但程序运行的时候老是出现'invaild field name pricid'的错误,请问怎样解决???

解决方案 »

  1.   

    第一句改为
    query2.SQL.Add('update huowei,huowei1');
      

  2.   

    不行,错误信息变为'invaild use of keyword token:huowei1 set'
      

  3.   

    这样试试:
    query2.SQL.Add('update huowei');
    query2.SQL.Add('set huowei.pricid=huowei1.pricid,huowei.zizoid=huowei1.zizoid');
    query2.SQL.Add('from huowei1');  // <- 加上这句
    query2.SQL.Add('where huowei.stritemname=huowei1.stritemname and huowei.lngpositionid=huowei1.lngpositionid and huowei.strcustomname=huowei1.strcustomname and huowei.strfullname=huowei1.strfullname');
      

  4.   

    还是不行啊,加上query2.SQL.Add('from huowei1')会出现为'invaild use of keyword token:from'的错误