How to check time conflict in time table and if no time conflict then insert a new appointment ?
I want to book a room if there is no time conflict with exist none empty room.
So first how to write acode for checking time conflict in these two records at least and it returns 0 , then insert a new record if there is not time conflict.
i tried the following but it gives me these records below, also i tried count(*) and the result was 2 which is not correct, it supposed to be 0 .
i want to check time conflict depending on (day name) and both (start_time), (End_time)
SELECT t2.* FROM
Room_Information t1
INNER JOIN
Room_Information t2
on
(t1.Start_Time < t2.End_Time
and
t1.End_Time > t2.Start_Time) and (t1.Day_Name=t2.Day_Name) and t1.Schedule_ID = t2.Schedule_ID and t1.Term_ID=118 and t1.room_id=140 ;
and this is my table
Term_Desc| Ac_Course_Code| Day_Name| Time_Desc| End_Time| Room_No| Section_Name | Room_ID | Term_ID | Schedule_ID
Summer I 2001 | COS 25 | Sunday | 10.30 | 12.00 | 7001-M3017 | D1 | 140 | 150 | 18915
Summer I 2001 | COS 25 | Sunday | 14.00 | 15.00 | 7001-M3017 | D2 | 140 | 150 | 18928