当前位置:Gxlcms > 数据库问题 > mysql中between...and..的使用,及时间范围的查询

mysql中between...and..的使用,及时间范围的查询

时间:2021-07-01 10:21:17 帮助过:12人阅读

id="conCurrentCount" parameterType="map" resultType="int"> SELECT COUNT(*) FROM tbl_report_info <where> ActionTime BETWEEN #{startTime} AND #{endTime} </where> </select>

讲解:

SELECT * FROM tbl_student_info WHERE `height` between 1113 and 1122     

等同于:
SELECT
* FROM tbl_student_info WHERE `height` >= 1113 and `height` <= 1122
    SELECT * FROM tbl_student_info WHERE `createDate` between 20170101020304 and 20180101020304    
        等同于:
    SELECT * FROM tbl_student_info WHERE `createDate` >= 20170101020304 and `createDate` <= 20180101020304    

另外一种时间范围查询的方法如下:分别设定开始时间和结束时间:

<if test="endTime!=null and !&quot;&quot;.equals(endTime.trim())">
            AND m.endTime &lt; #{endTime}
        </if>
           <if test="startTime!=null  and !&quot;&quot;.equals(startTime.trim())">
            AND m.startTime &gt; #{startTime}
        </if>

 

mysql中between...and..的使用,及时间范围的查询

标签:student   范围   inf   equals   amp   post   current   test   pre   

人气教程排行