I have a table that I'm trying to query for myself, and I'm not sure how to do this.
Table Name: Schedule
- user_id
- Startdate
- Endate
- sequencyID
Situation: I have a series of lines where user_id = 0. This is an open schedule that someone might require. If the task is scheduled, it is assigned a specific user ID. This is where the difficult part arises. I am trying to select a user and display a schedule time that does not overlap with the fact that they have already been accepted or scheduled.
That's what i still have
SELECT *
FROM schedule
WHERE user_id = 123456;
It gives me all ranges of times a person has already taken
SELECT *
FROM schedule
WHERE user_id = 0;
. , , - whos user_id = 0, startdate/enddate .
, -
SELECT *
FROM schedule
WHERE user_id = 0
AND (loop through schedule rows testing for
(startdate < loopstartdate and enddate < loopstartdate) ||
(startdate > loopenddate)
. ? - , , , .