q_sql:='select x.qq, y.ww from x,y where x.qq=i and y.qq=i'

解决方案 »

  1.   

    不可以:
    q_sql:='select x.qq, y.ww from x,y where x.qq='+i+' and y.qq='+i;
    我假设i为一个变量 ,而且是数值型 的,如果是字符型 的,就是另外一种写法了
      

  2.   

    应该是inttostr(i)
    高手也有闪失,呵呵!
      

  3.   

    不可以;
    q_sql:='select x.qq, y.ww from x,y where x.qq=y.qq and x.qq='''+i+'''';
      

  4.   

    你的i是变量吧,像: Drate(鸟窝里的虫) 说的那样
    q_sql:='select x.qq, y.ww from x,y where x.qq='+i+' and y.qq='+i;
    用Format来写:
    如果是数值:
    q_sql:=Format('select x.qq, y.ww from x,y where x.qq= %d and y.qq=%d',[i,i])
    如果是字符:
    q_sql:=Format('select x.qq, y.ww from x,y where x.qq= %s and y.qq=%s',[i,i])
      

  5.   

    Drate(鸟窝里的虫) 你好!
    如果i是字符型该怎么做呢??
      

  6.   

    i是字符型:q_sql:='select x.qq, y.ww from x,y where x.qq='+''''+i+''''+' and y.qq='+''''+i+'''';