如果所有员工都忙碌(分配到预约),请删除时段

时间:2016-08-19 06:45:06

标签: sql

我有一个日历,客户将用它来选择日期,当选择日期时,如果所有员工在特定时间忙于我希望将其删除,弹出窗口会显示带有工作时间的下拉菜单从下拉菜单中

我的桌子:

schedule (ID, date, start_time,end_time,Customerid) 
appointment_Staff (id, ScheduleID, staffID,AdminID) 
working_Hours (id,start_time,end_time)

到目前为止:

SELECT WorkingHours 
FROM WorkingHours
EXCEPT
(
    SELECT StartTime 
    FROM Assign_Staff,Schedule1 
    WHERE Assign_Staff.ScheduleId = Schedule1.ScheduleID 
    AND EXISTS 
    (
        SELECT ScheduleID, StartTime 
        FROM Schedule1 
        WHERE Date='2016-08-16'
    )
)

SELECT DISTINCT StaffID, WorkingHours 
FROM Staff, WorkingHours
EXCEPT
(
    SELECT StaffID, StartTime 
    FROM Assign_Staff, Schedule1 
    WHERE Assign_Staff.ScheduleId = Schedule1.ScheduleID 
    AND EXISTS 
    (
        SELECT ScheduleID, StartTime 
        FROM Schedule1 
        WHERE Date='2016-08-16'
    )
)

有人能指出我正确的方向吗?

0 个答案:

没有答案