比如有一数据库,里面有一字段为”名称“,是文本型的!SQL查询为: select * from ss where 名称='苹果'这时编译的时候就会出错!
我想应该是数据库里该字段的值并不是‘苹果’,而是‘苹果__’,里面带有
空格,所以查询出错,找不到默认值。
大家帮帮忙!要怎么样解决,才能正确查询!!

解决方案 »

  1.   


    with adoquery1 do
    begin
      active:=false;
      sql.add('select * form ss where name='+''''+'苹果'+'%'+'''');
      active:=true;
    end;
    _________________________
    最新上传六张软件界面, 
    http://expert.csdn.net/Expert/topic/1649/1649010.xml?temp=.4528009
    请大家继续关注此贴
    http://www.feichuang.com/unfurl.htm  谢谢
      

  2.   

    sql.add('select * form ss where name'+' like '+''''+'%'+'苹果'+'%'+'''');
      

  3.   

    用trim把空格去了不行吗?
      

  4.   

    那就不要空格
    用trim把空格去掉
      

  5.   

    怎么去掉空格??bluespy的不是精确查询啊!! My_first的('select * form ss where name='+''''+'苹果'+'%'+'''')的也不能精确查询啊!!
    因为字段值里的空格数是不固定的,怎么才能作到精确查询!!
      

  6.   

    'select * from ss where 名称='+quotedstr('苹果');
      

  7.   

    ADOQuery1.SQL.Text:='select * from ss where 名称='+quotedstr('苹果');
      

  8.   

    select * from ss where fields like '苹果%'
      

  9.   

    with adoquery1 do
    begin
      close;
      sql.clear;
      sql.add('select * from ss where 名称='+quotedstr('苹果')');
      open;
    end;
      

  10.   

    name:=trim(fildbyname('苹果').AsString)
      

  11.   

    它报什么错误?
    还有,模糊查询请用like而非-