如果在text1中输入“机”,怎样把数据表abc中的字段inf中的“机”、“计算机”、“机会”、“计算机,需要软件支持”之类的字符都查询出来?
这样的sql查询语句怎样写?
我试过sql="select * from abc where inf='*'+'text1.text'",只能查到“*”或者“机*”。
请教高手,谢谢!!

解决方案 »

  1.   

    sql="select * from abc where inf like '%机%'"
      

  2.   


    Sql="select * from 表名 where 字段 like'%"& textbox.text &"%'"
     
    %就跟windows中的查询通配符一个意思
      

  3.   

    没错
    Sql="select * from 表名 where 字段 like'%"& textbox.text &"%'"
      

  4.   

    sorry 刚才没有看见上面的
    sql="select * from abc where inf like '%"& text1.text &"%'"
      

  5.   

    那不是SQL语句问题,在其它地方找找原因
      

  6.   

    如果你的是acesss就是这样
    sql="select * from abc where inf like '*"& text1.text &"*'"
    就是把“%”,改成"*"
    access中匹配多个字符用*,Sql serve用%
      

  7.   

    flyingscv(zlj):我是用的access,但是按你说的写进去还是不行,有其他的什么可能性问题吗?
      

  8.   

    sql="select * from abc where inf like '*机*'"
    不行?
      

  9.   

    sql="select * from abc where inf like '*"& trim(text1.tex)t &"*'"
      

  10.   

    sql="select * from abc where instr([inf],'" & text1.text & "')>0"