1.时间范围
1.1create_time是datetime类型,参数带时分秒(yyyy-MM-dd HH:mm:ss)
SELECT e.create_time DATA FROM sys_enforce_event e WHERE e.create_time BETWEEN '2019-03-22 09:39:33' AND '2019-03-25 15:17:51'
查询结果如下图:
结论: 若datetime类型时,查询参数带时分秒,BETWEEN AND相当于 x >= y && x<=z。即包含头尾。
1.2create_time是datetime类型,参数不带时分秒(yyyy-MM-dd)
SELECT e.create_time DATA FROM sys_enforce_event e WHERE e.create_time BETWEEN '2019-03-22' AND '2019-03-25'
查询结果如下图:
结论: 若datetime类型时,查询参数不带时分秒,BETWEEN AND相当于 x >= y && x<z。即只包含头。
1.2create_time是date类型,参数(yyyy-MM-dd)
SELECT l.create_time FROM sys_enforce_black_list l WHERE l.create_time BETWEEN '2019-02-01' AND '2019-03-02'
查询结果如下图:
结论: 若date类型时,BETWEEN AND相当于 x >= y && x<=z。
2.数字范围
SELECT l.release_state FROM sys_enforce_black_list l WHERE l.release_state BETWEEN 1 AND 4
如图所示: