<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解析 < 、>、<=、>= 時會出錯,這時應該使用轉義寫法。
方式一
< <= > >= & ' "
< <= > >= & ' "
示例:
num >= #{num}
命名由來(gt、lt):
方式二
<![CDATA[ sql語句 ]]>
示例:
num <![CDATA[ >= ]]> #{num}
