NATURAL JOIN & USING Clause (and Why to Avoid NATURAL JOIN)
Use USING for shared key names and avoid brittle NATURAL JOIN surprises.
In plain words
USING joins on a column with the same name in both tables. NATURAL JOIN guesses which columns to join on, and can guess wrong.
Think of it like…
USING is saying "match people by their employee number". NATURAL JOIN is saying "match people on everything your two lists have in common": fine until both lists gain a "date added" column and nobody matches any more.
Where you’ve seen it
A schema where every foreign key repeats its parent's key name (orders.customer_id, customers.customer_id) can write SELECT customer_id, name, amount FROM orders JOIN customers USING (customer_id);. With NATURAL JOIN, adding updated_at to both tables would make the join require equal update timestamps too.
Words you’ll hear
- USING (cols)
- Join on the listed columns, which must have the same name in both tables.
- Merged column
- With USING, the join column appears once in the output.
- NATURAL JOIN
- Joins on all columns with matching names, chosen implicitly.
- Support
- PostgreSQL, MySQL, Oracle and SQLite support both; SQL Server supports neither.
Visual diagram
Theory & example queries
JOIN … USING
USING (a, b) means ON left.a = right.a AND left.b = right.b, and the output has a single a and b column rather than one from each table. You can refer to the merged column without a table prefix, which keeps SELECT lists short. With outer joins, the merged column takes whichever side's value isn't NULL.
It only works when the key has the same name in both tables, which favours naming foreign keys after the parent's key (customer_id in both customers and orders) rather than a generic id. If the parent's key is just id, you need ON.
| id | name | city | |
|---|---|---|---|
| 1 | Maya | maya@example.com | Pune |
| 2 | Ravi | ravi@example.com | Delhi |
| 3 | Noor | noor@example.com | Mumbai |
| id | customer_id | status | amount | coupon_code |
|---|---|---|---|---|
| 101 | 1 | paid | 249 | NULL |
| 102 | 2 | paid | 120 | WELCOME10 |
| 103 | 1 | shipped | 89.5 | NULL |
| id | order_id | product_id | qty | price |
|---|---|---|---|---|
| 1 | 101 | 42 | 2 | 49.5 |
| 2 | 101 | 84 | 1 | 150 |
| 3 | 102 | 42 | 1 | 49.5 |
SELECT order_id, customer_id, product_id, qtyFROM orders JOIN order_items USING (order_id) JOIN customers USING (customer_id);PostgreSQL is the lesson baseline unless noted otherwise.
Calculate the selected expressions and return the requested output columns.
Representative joined rows3 sample rows
| order_id | customer_id | product_id | qty |
|---|---|---|---|
| 9001 | 7 | 41 | 2 |
| 9001 | 7 | 56 | 1 |
| 9002 | 8 | 41 | 4 |
Note: Sample data assumes both orders have matching customers and each selected order item satisfies the USING joins.
Key takeaway: USING = ON with matching names, output column shown once.
Why NATURAL JOIN is risky
NATURAL JOIN decides the join columns from the current table definitions. Adding a column with a common name (status, created_at, updated_at, name) to both tables silently adds it to the join condition, and the query keeps running but returns far fewer rows. If the tables share no column names, it becomes a cross join.
Because the condition isn't written anywhere, readers can't tell from the query what it joins on. Most style guides ban NATURAL JOIN in production code. SQL Server supports neither NATURAL JOIN nor USING, so ON is also the most portable choice.
| id | name | city | |
|---|---|---|---|
| 1 | Maya | maya@example.com | Pune |
| 2 | Ravi | ravi@example.com | Delhi |
| 3 | Noor | noor@example.com | Mumbai |
| id | customer_id | status | amount | coupon_code |
|---|---|---|---|---|
| 101 | 1 | paid | 249 | NULL |
| 102 | 2 | paid | 120 | WELCOME10 |
| 103 | 1 | shipped | 89.5 | NULL |
SELECT *FROM orders NATURAL JOIN customers;PostgreSQL is the lesson baseline unless noted otherwise.
Calculate the selected expressions and return the requested output columns.
One possible post-migration match1 sample row
| customer_id | updated_at | order_id | amount | name |
|---|---|---|---|---|
| 7 | 2026-11-19 10:15:00 | 9001 | 249.5 | Asha |
Note: This assumes the only surviving NATURAL JOIN keys are customer_id and updated_at and exactly one order/customer pair shares the timestamp. The result can be empty for the same reason.
worked when the only shared column was customer_id. After a migration adds updated_at to both tables, it only returns pairs updated at exactly the same moment, which is almost none.
Key takeaway: Avoid NATURAL JOIN; use USING or ON.
How it works, step by step
Follow one practical SQL workflow from start to finish. Select any step or play through the flow.
Check the key names
See whether the join columns have the same name in both tables (customer_id and customer_id).
orders.customer_id · customers.customer_id
When to use it & trade-offs
What it is
JOIN … USING (col) is shorthand for joining on columns that have the same name in both tables: orders JOIN customers USING (customer_id). The result shows that column once instead of twice. NATURAL JOIN goes further and joins on *every* column name the two tables share, automatically, which is why it's widely considered dangerous.
Why it matters: USING makes joins on consistently named keys shorter and clearer. NATURAL JOIN can change silently when someone adds a column with a common name like created_at or status to both tables, turning a working report into one that returns almost nothing. Interviewers ask about it to see whether you know that risk.
When to reach for it
- USING in schemas with consistent key names
- ON for everything else and for portable SQL
- Explaining why NATURAL JOIN is discouraged
When to avoid or be careful
- NATURAL JOIN in production queries
- USING when the code must also run on SQL Server
- Generic id primary keys if you want to use USING
ON vs USING vs NATURAL JOIN
Strengths: Explicit, flexible and supported everywhere.
Watch out: Slightly longer; join columns appear twice in SELECT *.
Strengths: Concise; join column appears once.
Watch out: Not in SQL Server; needs consistent naming.
Strengths: Shortest possible syntax.
Watch out: Join columns are implicit and change when the schema changes.
Interview signals & numbers to know
When this topic comes up
- “What does NATURAL JOIN do?”
- “A report broke after a migration added a column”
- JOIN … USING in existing code
- SQL style guides
- Ambiguous column errors
Benchmarks & rules of thumb
- 1
- copy of each USING column in the output
- All shared names
- used by NATURAL JOIN
- 0
- support for USING in SQL Server
Common mistakes & follow-ups
Common interview mistakes
- Using NATURAL JOIN and having it silently include updated_at after a schema change.
- Trying USING (id) when the foreign key is called customer_id.
- Porting PostgreSQL code with USING to SQL Server and getting syntax errors.
Likely interviewer follow-ups
- What's the difference between JOIN … USING and NATURAL JOIN?
- Why do many teams forbid NATURAL JOIN?
- What happens to the join column in the output when you use USING?
Knowledge check
Put it into practice
Practice related interview Q&A
Apply NATURAL JOIN & USING Clause (and Why to Avoid NATURAL JOIN) with hands-on SQL practice and interview Q&A.