標籤:student 範圍 inf equals amp post current test pre
博主原創,轉載註明出處:
在mysql應用中,以範圍進行查詢的很多是以時間範圍作為條件進行範圍查詢的,時間範圍查詢有
很多種寫法,首先總結一下between....and...的使用方法:
<select 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 !"".equals(endTime.trim())"> AND m.endTime < #{endTime} </if> <if test="startTime!=null and !"".equals(startTime.trim())"> AND m.startTime > #{startTime} </if>
mysql中between...and..的使用,及時間範圍的查詢