我想执行语句:select * from ykmx where 序号  like '121%'。
  我是这样写的:
  Query1.SQl.Add( 'select * From ykmx where 序号  like '''12'''+inttostr(i) +'''%'''')。
  可我为什么得到的却是
select * from ykmx where 序号  like '12'1'%'。应该如何写呢?

解决方案 »

  1.   

    Query1.SQl.Add( 'select * From ykmx where 序号  like '+''''+12+''''+inttostr(i)+'%');
      

  2.   

    My_first(小@_@小) :
    明显:''''+12+''''这个有问题
      

  3.   

    哈哈。。
    Query1.SQl.Add( 'select * From ykmx where 序号  like ''''12'+inttostr(i) +'%'''''')。
      

  4.   

    Query1.SQl.Add( 'select * From ykmx where 序号  like ''''12'+inttostr(i) +'%''''')。
    或:
    Query1.SQl.Add( 'select * From ykmx where 序号  like "12'+inttostr(i) +'%"')。
      

  5.   

    这个序号应该是字符型吧
    Query1.SQl.Add( 'select * From ykmx where 序号  like '12'+inttostr(i) +'%'')。
    试试先!
      

  6.   

    我这样写了:
    Query1.SQl.Add( 'select * From ykmx where 序号  like ''''12'+inttostr(i) +'%''''')。可是报错:
      语法错误(操作符丢失)在查询表达式
      

  7.   

    Query1.SQl.Add( 'select * From ykmx where 序号  like "12'+inttostr(i) +'%"')
    呢?
      

  8.   

    Query1.SQl.Add( 'select * From ykmx where 序号  like ''''12'+inttostr(i) +'%''''')
    //--------------------------^^5个'
      

  9.   

    Query1.SQl.Add( 'select * From ykmx where 序号
      like ''''12'+inttostr(i) +'%''''')
    //--------------------------^^5个'
      

  10.   

    Query1.SQl.Add( 'select * From ykmx where 序号  like "12'+inttostr(i) +'%"');
    楼主没试吗?
      

  11.   

    会不会是数据库的问题,我用的是ACcess7
      

  12.   


    showmessage(query1.sql.text);
    看看出来的是什么!
      

  13.   

    select * from ykmx where 序号  like '121%'
      

  14.   

    另外的相似一句执行正常,只不过是like '1%'