sorry for the bad title. couldn't think of anything more descriptive.
I have the following tables to consider:
jobs
jobID int(11) PRIMARY
jobDate datetime
installers
installerID int(11) PRIMARY
installerName varchar(255)
jobInstallers
jobID int(11) (FK)
installeriD int(11) (FK)
(indexed as primary across the two cols)
installerHoliday
installerID int(11) FK
holidayDate datetime
(indexed as for jobInstallers)
the jobInstallers table is a many to many join table
jobDate is null in the jobs table until a job is assigned to a date
installerHoliday stores a record of which installers are off on which day
so ... what I am after is a query that delivers the installers that are free on a particular day. i.e. not on holiday and not already booked on a job. I can do this programmatically in php, though multiple queries. But I am forever advising people in the php forum to do more within their sql code. So practising what I preach, I wonder whether this can be reduced to a query?
any ideas appreciated. The table structure is simplified but hopefully i've given all you need.
Justin
I have the following tables to consider:
jobs
jobID int(11) PRIMARY
jobDate datetime
installers
installerID int(11) PRIMARY
installerName varchar(255)
jobInstallers
jobID int(11) (FK)
installeriD int(11) (FK)
(indexed as primary across the two cols)
installerHoliday
installerID int(11) FK
holidayDate datetime
(indexed as for jobInstallers)
the jobInstallers table is a many to many join table
jobDate is null in the jobs table until a job is assigned to a date
installerHoliday stores a record of which installers are off on which day
so ... what I am after is a query that delivers the installers that are free on a particular day. i.e. not on holiday and not already booked on a job. I can do this programmatically in php, though multiple queries. But I am forever advising people in the php forum to do more within their sql code. So practising what I preach, I wonder whether this can be reduced to a query?
any ideas appreciated. The table structure is simplified but hopefully i've given all you need.
Justin