>我有下表,其中存储了教师的课堂例程
表名:batchroutine_regular
batchid class_day subject teacherid class_start class_end
1 Sunday English-1 1001 02:00 PM 03:30 PM
1 Sunday Geography 1002 04:00 PM 05:30 PM
2 Monday Math 1001 10:00 AM 12:30 PM
2 Tuesday Geography 1001 01:00 PM 03:30 PM
现在假设您是teacherid
1001
的老师。您被要求在星期一上课,该课程将从11:00 AM
开始,到1:00 PM
结束。现在我的问题是 MYSQL/PHP 查询是什么,以从表格batchroutine_regular
中找出您当时是否有空?
提前致谢:)
SELECT (COUNT(*) = 0) AS Available
FROM batchroutine_regular
WHERE
teacherid = 1001
AND class_day = 'Sunday'
AND (
(class_start <= MAKETIME(11,00,00) AND class_end >= MAKETIME(11,00,00))
OR (class_start <= MAKETIME(13,00,00) AND class_end >= MAKETIME(13,00,00))
)