In this video, explore a solution to the set operator challenge and learn about the methodology used to solve this and similar challenges.
- [Instructor] Let's start with a naive approach. … I'm going to use the exact same queries … that returned the animals that were never adopted … and try to just change name to breed. … What could go wrong, right? … First, the outer join. … Change name to breed and execute, nice. … I do get the correct breed result, Turkish Angora cat, … but it's buried in a pile of wrong ones. … Let's see what this query really does. … And to do that, I'll follow query execution order. … Animals left outer join adoptions on species … and name returns all animals and for those … that were adopted, we also get their adoption attributes. … The ones that were not adopted will have null … for all adoption attributes and the … where filter keeps only those. … We get a list of all animals that were never adopted. … So far, same as before. … This set of 30 animals now moves on to the select clause, … in which we do two things. … We select only species and breed attributes … and remove duplicates with distinct. …
This course was created by Ami Levin. We are pleased to offer this training in our library.