由一个变量a
表b中有字段c
sql.add('select c from b where c=a');语句错误,该如何写

解决方案 »

  1.   

    sql.add('select c from b where c='+''''+a+'''');
      

  2.   

    sql.add('select c from b where c=:aa');
    parambyname('aa').asstring:=a;
      

  3.   

    如果c是字符型,楼上就行。
     如果是int
     sql.add('select c fom b where c='+IntToStr(a));
      

  4.   

    字段C为字符型:
    sql.add('select c from b where c='+''''+a+'''');
    字段为数值型:
    sql.add('select c from b where c='inttostr(a));