ianjking
07-22-2004, 04:09 PM
Having trouble figuring this one out for scheduling vacation.
Table staffavailable has two columns: userid and Date
The data would be that user1 on 2004-04-15 would be out of town.
User 1 might have 5 entries in the table for the five days off.
I want to pull a list of available staff by joining with a staff table.
What I am trying to do is return all the staff who do not have an entry listed in the staffavailable table for that day. My current statement is...
SELECT * FROM staff
LEFT JOIN staffavailable ON staff.UID = staffavailable.UID
WHERE staff.employmentStatus = 'y'
AND staffavailable.date != '20040412'
ORDER BY lastName
The problem with this is that if the user has more than one vacation day then they have more than one entry and they are returned as available.
I have been thinking over this for two hours now and my brain hurts, any ideas????
Thanks!
Table staffavailable has two columns: userid and Date
The data would be that user1 on 2004-04-15 would be out of town.
User 1 might have 5 entries in the table for the five days off.
I want to pull a list of available staff by joining with a staff table.
What I am trying to do is return all the staff who do not have an entry listed in the staffavailable table for that day. My current statement is...
SELECT * FROM staff
LEFT JOIN staffavailable ON staff.UID = staffavailable.UID
WHERE staff.employmentStatus = 'y'
AND staffavailable.date != '20040412'
ORDER BY lastName
The problem with this is that if the user has more than one vacation day then they have more than one entry and they are returned as available.
I have been thinking over this for two hours now and my brain hurts, any ideas????
Thanks!