码迷,mamicode.com
首页 > 其他好文 > 详细

3.MyBatis常用

时间:2019-05-09 09:20:40      阅读:113      评论:0      收藏:0      [点我收藏+]

标签:collect   tor   end   use   style   ring   date   格式   alt   

1.数据库日期转格式

DATE_FORMAT(measuring_time, ‘%Y-%m-%d‘) AS measuring_time,

 

2.日期大于小于

<if test="beginDate != null and beginDate != ‘‘">
  AND DATE_FORMAT(measuring_time, ‘%Y-%m-%d‘) >= #{beginDate}
</if>
<if test="endDate != null and endDate != ‘‘">
  AND DATE_FORMAT(measuring_time, ‘%Y-%m-%d‘) <= #{endDate}
</if>

 

3.foreach写法

 

<if test="healthStatuses != null">
  AND ha.health_status IN
  <foreach collection="healthStatuses" item="item" index="index" open="(" close=")" separator=",">
    #{item}
  </foreach>
</if>

 

 

4.模糊搜索

<if test="teamName != null and teamName != ‘‘ ">
  AND team_name LIKE CONCAT(‘%‘, #{teamName} ,‘%‘)
</if>

 

3.MyBatis常用

标签:collect   tor   end   use   style   ring   date   格式   alt   

原文地址:https://www.cnblogs.com/yslu/p/10836473.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!