gungrave19
New member
- Local time
- Today, 08:51
- Joined
- May 6, 2013
- Messages
- 7
I have 3 main tables: tblEmployees, tblJobs, and tblProcedures. (See attachment for relationship diagram and additional supplemental tables)
A job can have multiple procedures and an employee can have multiple procedures too.
I need to write a query such that when searching by a specific job I can see all of the employees who are qualified for that job. This is done by seeing which employees have the procedures that belong to a job. But here's the catch: since a job can have multiple procedures, if an employee only has some of the procedures I don't want that particular employee to return as a search result. The employee must have ALL the procedures that belong to the selected job.
So for instance if I have:
tblJobs
Job1
tblEmployees
Emloyee1
Employee2
tblProcedures
Procedure1
Procedure2
Job1 has Procedure1 and Procedure2
Employee1 only has Procedure1
Employee2 has both Procedure1 and Procedure2
If I search by Job1, I want only Employee2 to return as a result, NOT Employee1.
I am at a lost for how to construct the SQL for something like that. Can anyone point me to an article on how to do this or give me a general structure for this type of query?
Thanks in advance for any help!
A job can have multiple procedures and an employee can have multiple procedures too.
I need to write a query such that when searching by a specific job I can see all of the employees who are qualified for that job. This is done by seeing which employees have the procedures that belong to a job. But here's the catch: since a job can have multiple procedures, if an employee only has some of the procedures I don't want that particular employee to return as a search result. The employee must have ALL the procedures that belong to the selected job.
So for instance if I have:
tblJobs
Job1
tblEmployees
Emloyee1
Employee2
tblProcedures
Procedure1
Procedure2
Job1 has Procedure1 and Procedure2
Employee1 only has Procedure1
Employee2 has both Procedure1 and Procedure2
If I search by Job1, I want only Employee2 to return as a result, NOT Employee1.
I am at a lost for how to construct the SQL for something like that. Can anyone point me to an article on how to do this or give me a general structure for this type of query?
Thanks in advance for any help!