Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing
Back
  1. Home
  2. Interview prep
  3. What is NATURAL JOIN?

SQL · Basics & Joins

What is NATURAL JOIN?

Mediumsql-10
natural joinexplicit join

Question

What is NATURAL JOIN?

Solution

NATURAL JOIN automatically joins tables using columns with the same names.

Example:

SELECT *
FROM customers
NATURAL JOIN orders;

The problem is that the join condition isn't explicitly written.

Suppose today both tables have:

customer_id

and tomorrow someone adds another column with the same name, the behavior of the query could unexpectedly change.

That's why production SQL usually prefers explicit joins:

ON customers.customer_id = orders.customer_id

How to say it:

> NATURAL JOIN is dangerous because schema changes can silently change the join condition.

🎯 Put this concept into practice

Solidify this answer with real hands-on interview drills in the browser studio.

Open related drill →
PreviousNext