mybatis中使用大于小于等于的正確方法
在mybatis中sql是寫在xml映射文件中的,如果sql中有一些特殊字符的話,在解析xml文件的時候就會被轉(zhuǎn)義,如若不希望被轉(zhuǎn)義,那該怎么辦呢?
方法一:使用特殊轉(zhuǎn)義字符例如,>=開始日期 并且<=結(jié)束日期
> > 大于號
< < 小于號
<if test='searchTimeBegin != null and searchTimeBegin != ’’'> AND tcci.consume_time >= CONCAT(#{searchTimeBegin},’ 00:00:00’) </if> <if test='searchTimeEnd != null and searchTimeEnd != ’’'> AND tcci.consume_time <= CONCAT(#{searchTimeEnd},’ 23:59:59’) </if>
符號 小于 小于等于 大于 大于等于 和 單引號 雙引號 原符號 < <= > >= & ’ ' 替換符號 < <= > >= & ' "
方法二:使用<![CDATA[ ]]>符號這里面的內(nèi)容將不被解析
<if test='beginTime!=null'> AND DATE (os.show_start_time) >= DATE(#{beginTime}) </if> <if test='endTime!=null'> AND DATE (os.show_start_time) <![CDATA[<=]]> DATE(#{endTime}) </if>
在mybatis中<=不能使用,需要使用上面任意一種方法轉(zhuǎn)義,但是>=可以使用!
到此這篇關(guān)于mybatis中使用大于小于等于的正確方法的文章就介紹到這了,更多相關(guān)mybatis 大于小于等于內(nèi)容請搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!
相關(guān)文章:
1. Access數(shù)據(jù)庫安全的幾個問題2. Windwos下MySQL 64位壓縮包的安裝方法學(xué)習(xí)記錄3. mysql-bin.000001文件的來源及處理方法4. ACCESS轉(zhuǎn)SQL數(shù)據(jù)庫相關(guān)的幾個技能5. mysql 視圖操作和存儲過程6. mysql啟動時報錯 ERROR! Manager of pid-file quit without7. MySQL中InnoDB和MyISAM類型的差別8. MYSQL數(shù)據(jù)庫存文本轉(zhuǎn)存數(shù)據(jù)庫問題9. 如何實現(xiàn)MySQL數(shù)據(jù)庫的備份與恢復(fù)10. 數(shù)據(jù)庫相關(guān)的幾個技能:ACCESS轉(zhuǎn)SQL

網(wǎng)公網(wǎng)安備