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}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM