您的位置:首页 > 其它

多个条件查询 写法

2013-08-27 11:17 197 查看
  String where = "where 1=1";
  if(PERSON != null && !"".equals(PERSON)&& PERSON!=""){
where += " and p.PERSON like '%" + PERSON + "%'";
}
if(PRO_NAME != null &&!"".equals(PRO_NAME)&&PRO_NAME!=""){
where += " and p.PRO_NAME like '%" + PRO_NAME + "%'";
}
if(DOC_NAME != null && !"".equals(DOC_NAME) && DOC_NAME!=""){
where += " and l.DOC_NAME like '%" + DOC_NAME + "%'";
}
   sql="Select p.person,p.pro_name,l.doc_name,p.borrow_deadline,l.is_borrow,l.is_returned From loan_doc l Left Join pro_comp_info_borrow_reg p On p.guid=l.pro_guid "+where+"";
  //  然后去执行sql语句
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: