mybatis if choose ifelse 使用
来源:互联网 发布:吃鸡助手优化软件 编辑:程序博客网 时间:2024/06/08 09:11
以下内容为mybatis查询数据库的时候,使用 if else 判断
使用if
<if test="seat_no != null and seat_no != '' "> AND seat_no = #{seat_no} </if>个人没有找到 mybatis 中使用 if else 的情况,所以使用了 choose when 来替代
参考:
<choose> <when test="……"> …… </when> <otherwise> …… </otherwise> </choose>
以下是我自己真实使用的例子,并且经过了测试,仅供参考:
<select id="qryMultiRecords"parameterType="com.hundsun.cloudtrade.match.dto.req.QryHoldReq"resultType="com.hundsun.cloudtrade.match.domain.DayHoldDomain">SELECT firm_account ,seat_no ,stock_account ,exchange_type ,stock_name ,stock_code ,amount ,market_value ,position_str <choose><!-- 查询历史持仓表 --> <when test="hold_date != null and hold_date != '' "> ,hold_date FROM tb_history_hold </when> <!-- 查询当日持仓 --> <otherwise> ,'' hold_date FROM tb_day_hold </otherwise> </choose> WHERE firm_account = #{firm_account} <if test="seat_no != null and seat_no != '' "> AND seat_no = #{seat_no} </if> <if test="exchange_type != null and exchange_type != '' "> AND exchange_type = #{exchange_type} </if> <if test="stock_account != null and stock_account != '' "> AND stock_account = #{stock_account} </if> <if test="position_str != null and position_str != '' "> AND position_str = #{position_str} </if> ORDER BY stock_code DESC<if test="req_number != null and req_number != '' "> LIMIT 0,#{req_number} </if> ;</select>
阅读全文
0 0
- mybatis if choose ifelse 使用
- MyBatis动态SQL之一使用 if 标签和 choose标签
- MyBatis动态SQL之一使用 if 标签和 choose标签
- mybatis include choose when if
- <c:if><c:choose>使用
- Mybatis <where> <if> <set> <trim> <choose>标签
- MyBatis-动态SQL的if、choose、when、otherwise、trim、where、set、foreach使用
- MyBatis-动态SQL的if、choose、when、otherwise、trim、where、set、foreach使用
- mybatis choose标签的使用
- mybatis中choose的使用
- Mybatis的<if>和<choose>的区别 以及“=”判断
- Mybatis的动态sql语句if和choose
- Mybatis的动态sql语句if和choose
- Mybatis的动态sql语句if和choose
- ifelse和if的区别
- MyBatis动态SQL<choose>标签的使用
- R语言︱函数使用技巧(循环、if族/for、switch、repeat、ifelse、stopifnot)
- c.tld中<c:if>和<c:choose>的使用
- Python与机器学习之数据可视化
- 利用Tensorflow的Mobilenet模型在移动端进行舌像识别进行体质分类
- 在 CentOS7 上安装 Zookeeper-3.4.9 服务
- 安装sql Server2008 过程中遇到 属性不匹配。存在属性(Directory, Archive),包括属性(0),不包括属性(Archive, Compressed, Encrypted)。
- 深度学习方法(十一):卷积神经网络结构变化——Google Inception V1-V4,Xception(depthwise convolution)
- mybatis if choose ifelse 使用
- vue-axios整合使用
- php 使用array_map替代foreach 提取二维数组元素组装新数组
- Linux下如何查看硬盘硬件信息(hdparm命令、smartctl命令)
- Centos7 安装mysql5.6
- [Lintcode] #491 回文数
- whenever
- JSP新闻系统之三后台显示页面
- pulltorefreshdemo 上拉下拉