最开始我的使用是
select * from admin where (adminid like ‘‘ or adminid is null) or (adminpwd like ‘‘ or adminpwd is null);
但是无法实现所有条件为空时查询全部,后来突然明白我为什么要这样设置sql语句我可以拼接字符串啊
于是
String sql=“select * from admin”; if(adminname!null){ sql+=“where adminname like ‘%参数%‘; }else if(xxx){ sql+=xxx } selectsql(sql);//调取查询语句