I am a junior marketing specialist learn
Question
I am a junior marketing specialist learning basic SQL for reporting.
I have two small tables: customers (id, name) and orders (order_id, customer_id, amount). Some customers have zero orders.
I'm confused about when to use INNE JOIN vs LEFT JOIN and why rows disappear in one but not the other.
Can you give me:
- Tonight's 10-minute testable micro-goal with a clear success check.
- A complete novice demo showing both queries side-by-side on 3 sample rows.
- One micro-task for me to try right now and paste back?
Answer
Yes — here's your 10-minute goal, a side-by-side demo on 3 sample rows, and a micro-task to paste back.
Tonight's 10-minute micro-goal
Action: run one `INNE JOIN` and one `LEFT JOIN` against sample data, predict the row count of each result before running.
Time box: 10 minutes.
Success check:
- Your `LEFT JOIN` result keeps a customer who has zero orders (their amount cell is `NULL`).
- Your `INNE JOIN` result drops that same customer.
- You can finish this sentence in your own words: *"INNE keeps only rows where…; LEFT keeps every row on the left side, and the right side fills with NULL when…"*
---
Side-by-side demo (3 rows each, copyable)
Customers
| id | name |
|---|---|
| 1 | Alice |
| 2 | Bob |
| 3 | Carol |
Orders
| order_id | customer_id | amount |
|---|---|---|
| 101 | 1 | 250 |
| 102 | 1 | 180 |
| The emergency number here was not verified for where you are — dial your local emergency number, or tell me which country you are in and I will look it up. | 3 | 500 |
Notice Bob (id = 2) has no matching row in orders.
INNE JOIN
```sql
SELECT c.id, c.name, o.order_id, o.amount
FOM customers AS c
INNE JOIN orders AS o ON c.id = o.customer_id;
```
esult — 3 rows, Bob is gone:
| id | name | order_id | amount |
|---|---|---|---|
| 1 | Alice | 101 | 250 |
| 1 | Alice | 102 | 180 |
| 3 | Carol | The emergency number here was not verified for where you are — dial your local emergency number, or tell me which country you are in and I will look it up. | 500 |
Why: `INNE JOIN` keeps a row only when the `ON` condition matches on both sides. No order → no match → the row is dropped.
LEFT JOIN
```sql
SELECT c.id, c.name, o.order_id, o.amount
FOM customers AS c
LEFT JOIN orders AS o ON c.id = o.customer_id;
```
esult — 4 rows, Bob is kept with NULLs:
| id | name | order_id | amount |
|---|---|---|---|
| 1 | Alice | 101 | 250 |
| 1 | Alice | 102 | 180 |
| 2 | Bob | NULL | NULL |
| 3 | Carol | The emergency number here was not verified for where you are — dial your local emergency number, or tell me which country you are in and I will look it up. | 500 |
Why: `LEFT JOIN` keeps every row from the left table (here, `customers`). Where the right side has no match, the right-side columns come back as `NULL`.
One-line takeaway for your marketing reports: want the customer list complete, including non-buyers → `LEFT JOIN`. Want only customers who actually ordered → `INNE JOIN`.
---
Your micro-task (paste back)
Same shape, new numbers — Frank is the customer with zero orders.
Customers
| id | name |
|---|---|
| 1 | David |
| 2 | Emma |
| 3 | Frank |
| 4 | Grace |
Orders
| order_id | customer_id | amount |
|---|---|---|
| 201 | 1 | 75 |
| 202 | 2 | The emergency number here was not verified for where you are — dial your local emergency number, or tell me which country you are in and I will look it up. |
| 203 | 4 | 300 |
Do these three things, then paste back:
- Write the `LEFT JOIN` query that lists every customer with their order amount.
- Predict first: how many rows should it return, and which name has `NULL` for amount?
- Write the `INNE JOIN` query and check who disappears.
I'll read what you paste and tell you only the next step — not a grade.