From the course: Advanced SQL: High Performance Relational Divisions

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Solution: Exact relational division

Solution: Exact relational division - SQL Tutorial

From the course: Advanced SQL: High Performance Relational Divisions

Start my 1-month free trial

Solution: Exact relational division

- [Instructor] Okay, here is the ordinary relational division. The key is to realize that the additional condition for the exact division can also be phrased in double negative. And only those who have no extra skills can be rephrased as and only those for whom there isn't a skill that they possess that isn't required for the DB Architect role. Isn't, isn't, double negative. And that, too, translates literally to SQL. And only those for whom there isn't and not exists a skill. Select whatever from candidate skills, let's give it a different alias, and correlate the candidate to the outer query that isn't required and not exist for the DB Architect role. Select whatever from role skills where a role equal DB architect, and correlate the skill back to the parent query. Execute, bam. Chan is the man. Elegant, clear SQL at its best. A small cosmetic improvement is an order. This time the subquery for the DB…

Contents