0

我有一个包含 2 列 startdate 和 enddate 的表,用于存储特定场所中有趣节目的开始和结束时间。(两列的格式均为 datetime-format 为 'Ymd H:i:s')。当用户创建a program within this time limitthe end time of the program lies within the time limit but not the start timethe start time lies within the time limit but not the end time,程序不应插入显示警报的表中。我已经编写了这样的查询。但它不能正常工作。

SELECT * FROM tbl_venue WHERE venue_id='id' AND
((venue_start_datetime BETWEEN 'entered starttime' AND 'entered end time')
AND (venue_stop_datetime BETWEEN 'entered starttime' AND 'entered end time'))    

提前致谢。

4

2 回答 2

0

尝试这个:

SELECT * 
FROM tbl_venue 
WHERE venue_id='id' AND
'entered starttime' >= venue_start_datetime
AND 'entered end time' <= venue_stop_datetime
AND 'entered starttime' <= 'entered end time'
于 2013-03-05T15:24:04.647 回答
0

您只需要测试输入的 startdate 是否在 start 和 enddate 之间,或者 entererd enddate 是否在 start 和 enddate 之间

SELECT * FROM tbl_venue WHERE venue_id='id' AND
('entered starttime' BETWEEN venue_start_datetime AND venue_stop_datetime
OR 'entered endtime' BETWEEN venue_start_datetime AND venue_stop_datetime)
于 2013-03-05T15:24:16.243 回答