mybatis中添加时间字符串条件

<if test="operatorDateStart != null and operatorDateStart !='' " >
operator_date >= #{operatorDateStart,jdbcType=VARCHAR}
</if>
<if test="operatorDateEnd != null and operatorDateEnd !='' " >
<![CDATA[
and operator_date <= concat(#{operatorDateEnd,jdbcType=VARCHAR},'235959')
]]>
</if>











sql 查询每天大于某个时间点的数据


select * from ( select bbb.action_id, aaa.image_id, aaa.version, aaa.create_time, aaa.marker_id, aaa.label_duration_second, DATE_FORMAT(aaa.create_time,'%H') time from t_shelf_label_history aaa inner JOIN t_shelf_image bbb ON aaa.image_id = bbb.id and bbb.owner_id = 2265 where aaa.create_time > "2018-10-1" AND aaa.create_time < "2018-10-31" ) demo where time > 20








yBatis中大于和小于号的转义写法
2018年09月10日 11:01:21 月下泛舟 阅读数:5629

mybatis 中 SQL 写在mapper.xml文件中,而xml解析 < 、>、<=、>= 时会出错,这时应该使用转义写法。

方式一
<     <=     >     >=     &     '     "
&lt;     &lt;=     &gt;     &gt;=     &amp;     &apos;     &quot;

示例:

num &gt;= #{num}

命名由来(gt、lt):

方式二

<![CDATA[  sql语句  ]]>

示例:

num <![CDATA[ >= ]]> #{num}

转载于:https://www.cnblogs.com/xiaoshen666/p/10772244.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值