In SQL Server (2008), I’d like to find all employees in a single table that have skillids of 3, 4, 5 or 4, 5, 6. They need to have one of those sets. Just having skillid=4, for example, should not produce a match. How do I construct this type of query?
An example table:
pkid, empid, skillid
1 2 3
2 2 4
3 2 5
4 5 6
In the above example, empid=2 is a match for the set 3,4,5. empid=5 is not.
You will need to use a
GROUP BYand aHAVINGclause on the query:See SQL Fiddle with Demo