mybatis if-else(chose when otherwise )
mybaits 中没有else要用chose when otherwise 代替
详情可以参考此文章:mybatis if-else(写法)
我在项目中的写法如下:
<select id="searchCorpList" parameterType="java.lang.String"resultType="com.pccwhkt.ump.portal.umportal.sys.user.bean.SearchCorpResultBean">select CORP_ACC_ID, CORP_ID, CORP_ACC_NAME CORP_NAME, STATUS, TYPEfrom UMG_CORP_ACC<if test="corp_id != null and corp_id != ''">where LOCATE(#{corp_id}, CORP_ID)>0</if><if test="corp_name != null and corp_name != ''"><choose><when test="corp_id != null and corp_id != ''">and LOCATE(#{corp_name}, CORP_ACC_NAME)>0</when><otherwise>where LOCATE(#{corp_name}, CORP_ACC_NAME)>0</otherwise></choose></if><if test="status != null and status != ''"><choose><when test="(corp_id != null and corp_id != '') or (corp_name != null and corp_name != '')">and LOCATE(#{status}, STATUS)>0</when><otherwise>where LOCATE(#{status}, STATUS)>0</otherwise></choose></if><if test="type != null and type != ''"><choose><when test="(corp_id != null and corp_id != '') or (corp_name != null and corp_name != '') or (status != null and status != '')">and LOCATE(#{type}, TYPE)>0</when><otherwise>where LOCATE(#{type}, TYPE)>0</otherwise></choose></if></select>
mybatis if-else(chose when otherwise )相关推荐
- mybatis if-else(写法)
mybaits 中没有else要用chose when otherwise 代替 范例一 <!--批量插入用户--> <insert id="insertBusinessU ...
- mybatis高级查询,批量新增
review sql脚本 实体类 sql watch out mapper mapper test 之前的比较分散,自己用... sql脚本 -- auto-generated definition ...
- Hibernate 多表映射(Mybatis,Springjdbc,Hibernate ,JDBC的多表映射学习比较)
from:http://blog.zenika.com/index.php?post/2012/03/28/Presentation-de-MyBatis Mybatis,Springjdbc,Hib ...
- SSM框架专题-MyBatis框架老杜版从零入门笔记(下)
七.MyBatis参数处理 7.1 单个简单参数 parameterType表示传入参数的类型,官方文档有很多别名可以参考 <insert id="insertStu" pa ...
- MyBatis中if - else if - else 的使用
http://www.leftso.com/blog/765.html 不过有他的替代 choose,写法如下: <choose><when test="params!= ...
- mybatis使用<choose> <when>
mybatis使用<choose> <when> 一.需求 后台使用orcale数据库,mybatis做持久层,前台搜索功能,根据类型搜索,但是数据库中没有类型字段, 所以需要 ...
- mybatis的函数
mybatis的函数 1) with .. as ( select * from *) 相当于提取一个临时表,以便于复用,在union all中经常用到,以及需要复用的时候用到; 这是CTE的格式,使 ...
- mybatis 中 if else 用法
mybaits 中没有 else 要用 chose when otherwise 代替 下面就是MyBatis中的if....else...表示方法 <choose><when te ...
- mybatis查询报错:com.mysql.cj.exceptions.DataConversionException: Cannot determine value type from string
mybatis查询报错: com.mysql.cj.exceptions.DataConversionException: Cannot determine value type from strin ...
最新文章
- b树与b+树的区别_一篇文章理清B树、B-树、B+树、B*树索引之间的区别与联系
- 在NamedParameterJdbcTemplate中使用like查询
- 收藏!细胞增殖实验要点详解
- 究极日月服务器维护时间,超激斗梦境9月25日终极测试服务器维护公告_超激斗梦境9月25日更新了什么_玩游戏网...
- LEAGUE TABLES【模拟】
- Date-calendar 类
- Wireshark使用教程用户手册
- 小程序:npm下载使用weiui
- 解决百度云管家导入未完成下载任务
- 基于 Python 的时序模型——AMIRA模型
- 带阻滤波器对周期性噪声消除matlab实现
- 如何安装cnpm和检查cnpm是否已经安装成功
- Windows系统怎样配置PHP环境
- 【转】“产品策划大神 如何进行用户需求分析,这篇文章实在说的透彻!!!【互联网方向】
- 「硬见小百科」一文读懂电子元器件
- NB-IoT门磁报警器 物联网门磁传感器 电子封条报警器
- HTML和CSS做优惠券效果
- Linux(ubuntu16.04)FTP服务器搭建详细步骤
- Edge浏览器黑色背景设置
- 数据科学家是干什么的,成为一名数据科学家,主要划分为哪几个步骤?