tags:

views:

17

answers:

2

given a users qualification id's how would you find the jobs they can do using SQL?

1) for example a user with only qualification 1 could only do job3 and not 1 and 4 because you need more than one qualification. 2) a user with qualifications 1 and 2 could do jobs 1 and 3 but not 4

JOBDETAILS TABLE

JobID ,QualificationID

1, 1

1, 2

3, 1

4, 1

4, 2

4, 3

thanks for any help

TJ

A: 

you need to provide us info on your user table to write the full pseudo-query

Albert
A: 
SELECT DISTINCT JobID
FROM JobDetails
WHERE QualificationID IN (@Quals)
AND JobID NOT IN
(
  SELECT DISTINCT JobID
  FROM JobDetails
  WHERE QualificationID NOT IN (@Quals)
) 

(Apologies for syntax issues; I work with SQL Server, not MySQL)

Adam V