Home > Back-end >  Get list of workers with required skills
Get list of workers with required skills

Time:11-16

I have a table with the skills required to work. For example, the level of skill 1 needs to be 2 or higher, and the level of skill 2 needs to be 3 or higher. (Levels go from 1 to 4).

enter image description here

Then I have another table with the skills that each worker has.

enter image description here

How can I check which workers have all the skills required? In this case, only worker 2 has the skills required because the current level of skill 1 is higher or equal to the minimumlevel, and the same for skill 2.

Is this possible to do using just sql queries?

CodePudding user response:

I think you need SQL query like this:

SELECT W.Worker
FROM Workers W
INNER JOIN Skills S USING (Skill)
GROUP BY W.Worker
HAVING every(W.CurrentLevel >= S.MinimumLevel) -- for MySQL only
  •  Tags:  
  • sql
  • Related