select startip from emtb
where substr(str1,1,instr(str1,'.',1,3))=substr(startip
,1,instr(startip,'.',1,3)) and  substr(str1,1,instr(str1,'.',1,3))=substr(endip,1,instr(endip,'.',1,3))
and str2>st
and str2<end;现在假设192.168.0.1和60都是用户输入,对应delphi程序中的变量是str1和str2。
请问如何在query中写这条语句?
不胜利感谢!

解决方案 »

  1.   

    to:
    killlaoli 
    传递参数是什么意思,能不能详细点说明!
      

  2.   

    我记得是四个'代表在SQL里面的一个'
    给你一个例子:
    strwhere:='t_charge'='+''''+name+''''+'and ' +left(t_code,2)='+''''+adodatapro.fields[0].value+'''';
      

  3.   

    数引号太麻烦,用#39方便,又不容易出错。
    Sql := 'select startip from emtb ' + 
      'where substr(str1,1,instr(str1,' + #39 + '.' + #39 + 
      ',1,3))=substr(startip,1,instr(startip,' + #39 + '.' + 
      #39 + ',1,3)) and  substr(str1,1,instr(str1,' + #39 + 
      '.' + #39 + ',1,3))=substr(endip,1,instr(endip,' + #39 + 
      '.' + #39 + ',1,3)) and str2>st and str2<end'
    这样就可以了。
      

  4.   

    两个'就是#39,是这个意思吧?
    你还可以把字符串中的'改为''
    在asp中为:str1=replace(str1,"'","''")
    Delphi我不太了解!!!