sql="select * from 用户表 where 用户编号 not in( select 用户编号 from 回收站  ) and '"+type+"' like '%"+key+"%'";的到的结果 
select * from 用户表 where 用户编号 not in( select 用户编号 from 回收站 ) and '姓名' like '%天才说话%'因为 and '姓名' 的关系, 我什么也查不出来。
   但是去'' 又语法错误。。
   不知道该怎么解决。

解决方案 »

  1.   

    姓名是 数据库字段
       但是我是通过页面参数得到的
     "********  and "+姓名+" ";
      这样没语法错误吗?
      

  2.   

    既然姓名是数据库字段, 你这么写
    "********  and "+姓名+" ";
    表明姓名是变量了
      

  3.   

    这么写看看
    sql = "select * from 用户表 where 用户编号 not in(select 用户编号 from 回收站) and ";
    sql = sql + type + "like '%"+key+"%'";