Skip to content
Advertisement

SQL Select where column IN inclusive

I have two tables Person and Skill.

I have a join table:

I have two rows in the Person table

And Four rows in the Skill table

And the Join table has

I want to get a list of all people that have English, Math and Science as a skill (inclusive). A standard select

will retrieve both Bob and John.

How do I get the only results where all three skills are present?

Advertisement

Answer

Aggregate by person and then assert that all skills be present for each matching person:

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement