mybatis根據時間檢索查詢


寫原生sql雖然說麻煩,遇到問題排查的相對mybatis-plus也比較慢,但不得不說原生sql讀寫確實比較快,你要嫌寫原生sql的代碼量多的話也可以兩者整合着寫。

下面來說下mybatis對時間的檢索查詢,條件包括年、月、日。

1.時間段檢索查詢(兩時間段)

            <if test="beginTime != null and beginTime != ''">
                <!-- 開始時間檢索 --> and date_format(receive_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d') </if>
            <if test="endTime != null and endTime != ''">
                <!-- 結束時間檢索 --> and date_format(receive_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d') </if>

 

2.根據年、月查詢

and date_format(create_at,'%Y-%m')=#{createAt}

 

3.根據年、月、日查詢

and date_format(completion_time,'%y%m%d') = date_format(#{completionTime},'%y%m%d')

 

mybatis-plus篇

https://www.cnblogs.com/ckfeng/p/15667779.html


免責聲明!

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



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