以此表为例:
SELECT * FROM bill_segmentation_ocr.user_api_info where id between 40 and 41;
- between and 日期数值只包括左边界不包括右边界
SELECT * FROM bill_segmentation_ocr.user_api_info where createAt between '2020-1-12' and '2020-06-12';
知道了原因解决办法也有很多
①.通过date_add()将右边界加一天
SELECT * FROM bill_segmentation_ocr.user_api_info where createAt between '2020-1-12' and date_add('2020-6-12',interval 1 day);
SELECT * FROM bill_segmentation_ocr.user_api_info where date(createAt) between date('2020-1-12') and date('2020-06-12');
- not between and 左右边界都不包括
SELECT * FROM bill_segmentation_ocr.user_api_info where id not between 40 and 41;