between 的范围是包含两边的边界值
eg: id between 3 and 7 等价与 id >=3 and id<=7
eg:id not between 3 and 7 等价与 id < 3 or id>7
SELECT * FROM `test` where id BETWEEN 3 and 7;
等价于 SELECT * FROM `test` where id>=3 and id<=7;
-----------------------------------------------------------
SELECT * FROM `test` where id NOT BETWEEN 3 and 7;
等价于 SELECT * FROM `test` where id<3 or id>7;
边界问题:
mysql, between 开始日期 AND 结束日期 包含开始日期,不包含结束日期
例如:
BETWEEN '2018-01-22' AND '2018-01-30'
开始日期从2018-01-22 00:00:00.0 开始, 到2018-01-29 23:59:59.59结束
参考:https://www.jb51.net/article/214469.htm