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

Unlock the full course today

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

Solution: Hybrid multi-table join

Solution: Hybrid multi-table join - SQL Tutorial

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

Start my 1-month free trial

Solution: Hybrid multi-table join

- [Instructor] Let's see which tables are required. First, animals and vaccinations are obvious, we also need persons for the address, and staff assignments for the role of the staff member. Because the database uses the same identifier for a person throughout, we don't need any data from staff, which just saved us a whole join. If we were to use the surrogate key, staff ID, which in turn would point to a person ID, we would have no choice but to join staff as well. In my solutions, I always start from the from clause and list tables with inner joins first. Provide aliases, specify the qualification predicate, and now I can list all the select expressions and do a quick sanity test by executing this intermediate query. I also like to add an order by, so I can have immediate visual reference, even though it's not required by the challenge. Let's execute the query, and we're almost there. The only thing missing is to return…

Contents