例如,有table如下列:name,address, telephone等等,
我想从table表中模糊查找信息,输入框(edit1)输入的有可能是name列的关键字,或telephone列的关键字,怎么写两列的模糊查找呢?我这样写可以吗?
select name,address,telephone from table where name like '%'+edit1+'%' and telephone like  '%'+edit1+'%'

解决方案 »

  1.   

    噢,
    错了
    应该是or而不是and
    select name,address,telephone from table where name like '%'+edit1+'%' or telephone like  '%'+edit1+'%'
      

  2.   

    加几个引号:
    select name,address,telephone from table where name like ''%'+edit1+'%'' and telephone like  ''%'+edit1+'%'' ';
      

  3.   

    呵呵
    select name,address,telephone from table where name like ''%'+edit1+'%'' or telephone like  ''%'+edit1+'%'' ';
      

  4.   

    select name,address,telephone from table where name like '+#39+'%'+trim(edit1.txt)+'%'+#39+' or telephone like  '+#39+'%'+trim(edit1.txt)+'%'+#39