假设表名为temptable
字段为:tempname,tempage,tempsex,tempbirthday。
页面的变量为:name,age,sex,birthday查询条件为姓名,年龄,性别,生日时://这里假定你已经将变量取得,且为String型
sql分别为: select * from temptable where tempname='"+name+"'; 
            select * from temptable where tempage='"+age+"'; 
            select * from temptable where tempsex='"+sex+"';
            select * from temptable where tempbirthday='"+birthday+"'; 
如果查询姓名,条件为年龄。
sql为: select name from temptable where tempage='"+age+"'; 如果条件为复合的,比如年龄和性别。
那么sql可以是:
select name from temptable where tempage='"+age+"' and tempsex='"sex"'; 

解决方案 »

  1.   

    查询所有记录可以用
    select * from temptable;
      

  2.   

    你是指多条件还是多字段阿,没说清楚。
    多字段就用复选框罗,多条件就用几个下拉框来建立条件,然后再判断,然后再加到where字句里面罗。前两天刚帮一个mm做了一个。
      

  3.   

    更正,select name from temptable where tempage='"+age+"' and tempsex='"+sex+"'; 
      

  4.   

    我是这个意思:比如传来的参数已经得到
     我要查寻年龄为xx,性别为xx 生日为2001-01-01的 姓名所有的该怎么写
      

  5.   

    select tempname from temptable where tempage='xx' and tempsex='xx' and tempbirthday='2001-01-01';