The Brief
Wow, I can't believe we're on Day 3 already! In case you forgot, it's still John at Maven Analytics here.
Yesterday you found that INNER JOINs silently hide unmatched rows, and that LEFT JOINs are how you surface what's missing. Today we build on that with a framework for approaching any multi-table query, then use it to run the analysis Sarah actually needs.
Three questions before you write a multi-table query
Most people jump straight to writing the JOIN. That's how you end up with queries that work technically but answer the wrong question.
Before touching the keyboard, answer these:
1. Which table is the anchor? The table your question is fundamentally about. If the question is "what are customers buying?", the anchor is customers. If it's "which products are selling to which segments?", the anchor is orders, because orders link products to customers.
2. Which other tables do I need, and why? List them and the reason each is needed. If you can't say in one sentence why a table is necessary, you probably don't need it.
3. What type of JOIN does each connection need? All rows from the left side even with no match → LEFT JOIN. Only rows where both sides match → INNER JOIN. (And RIGHT JOINs as I mentioned yesterday are only for the crazy!)
Write through these three questions before every multi-table query for the next two weeks. It feels slow at first. Then it becomes instinct.