多个条件查询 写法
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语句
相关文章推荐
- 查询数据时,根据不同查询条件的情况,重载方法的一种写法(不知道怎么描述了!!!!)
- mysql 时间类型查询条件写法
- 查询条件TPH inheritance 查询的 3 种写法
- Laravel5 构造器高级查询条件写法
- Mybatis动态sql条件查询中if判断Integer的条件写法
- mysq中or的用法和多条件查询的写法
- Annotation注解归总&ID生成策略&联合主键及hql中的条件查询写法
- 必须知道的SQL编写技巧,多条件查询不拼字符串的写法
- 茴香豆的n种写法之②——Sql据多个条件 查询每个条件的前N条记录
- Oracle clob类型的字段作为查询条件的sql语句写法
- C# SqlServer 未定字段未定条件的组合查询写法
- python 中 MySQLdb 操作数据库,查询条件为元组时写法。
- 查询日期范围时SQL条件的写法
- FleaPHP框架数据库查询条件($conditions)写法总结
- oracle 查询当天数据的sql条件写法
- 必须知道的SQL编写技巧,多条件查询不拼字符串的写法
- 多字段查询,多条件查询写法
- sql通配符+sql中查询条件包含下划线等通配符的写法
- FleaPHP框架数据库查询条件($conditions)写法总结
- SQL Server 存储过程中处理多个查询条件的几种常见写法分析,我们该用那种写法