1. Home
  2. Data Science
  3. SQL for Data Analysis
  4. Why is NATURAL JOIN considered risky in production queries?

Added 30 Nov -0001

Why is NATURAL JOIN considered risky in production queries?

  1. It requires both tables to have identical column order for it to work
  2. It performs a cross join whenever the tables share no column name at all
  3. It joins on every same-named column, so a new column silently changes it Correct answer
  4. It joins only on primary keys, which the optimiser may guess incorrectly

Correct answer

C. It joins on every same-named column, so a new column silently changes it

16 views

MCQSEXAM

Explanation

NATURAL JOIN equates all columns that share a name across the two tables, so adding a column such as created_at to either table silently changes the join condition and the row count. It also removes the duplicate columns from the output, which can hide the mistake. Explicit ON or USING clauses keep the intent visible, reviewable and diffable in version control.

Reference

Asked in: NTS, PPSC IT, Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is C? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More SQL for Data Analysis MCQs

Practise all SQL for Data Analysis MCQs

Similar MCQs