From the course: Advanced SQL: Logical Query Processing, Part 2

Unlock the full course today

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

Solution

Solution - SQL Tutorial

From the course: Advanced SQL: Logical Query Processing, Part 2

Start my 1-month free trial

Solution

- [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…

Contents