我想选择start_time
和end_time
之间的所有行。我目前有这个查询。它工作正常但有些记录仍然存在,尽管它不在指定的时间范围内:
结构:
查询:
SELECT * FROM `tbl_subloading`
WHERE`start_time` >= '08:00AM' and `end_time`<= '09:00AM';
输出:
什么似乎是问题家伙?
答案 0 :(得分:0)
试试这个:
SELECT * FROM `tbl_subloading`
WHERE`start_time` between CAST('08:00:00' AS time) and
CAST('09:00:00' AS time) and `end_time` between
CAST('08:00:00' AS time) and CAST('09:00:00' AS time);
答案 1 :(得分:0)
找到消除不必要时间的方法。不知道这是否是一种有效的方式,但由于它做了我想要的,我认为这一切都很好。
SELECT * FROM `tbl_subloading`
WHERE `start_time` BETWEEN '08:00AM' and '09:00PM'
and `end_time` BETWEEN '08:00AM' and '09:00PM'