Difficulty: Easy
Correct Answer: Outer join
Explanation:
Introduction:
Joins combine rows from two or more tables. Sometimes, analysis requires keeping rows even when there is no matching counterpart in the other table. Recognizing the correct join type prevents accidental data loss and ensures complete reporting.
Given Data / Assumptions:
Concept / Approach:
An outer join (LEFT, RIGHT, or FULL) preserves rows from one or both input tables that have no match on the other side, padding the missing columns with NULLs. In contrast, inner joins (equi-joins and most natural joins) return only matching rows and therefore discard unmatched ones.
Step-by-Step Solution:
Choose LEFT OUTER JOIN to keep all rows from the left table plus matches from the right.Choose RIGHT OUTER JOIN to keep all rows from the right table plus matches from the left.Choose FULL OUTER JOIN to keep all rows from both tables, matching where possible and filling NULLs otherwise.Avoid inner-join-only approaches when unmatched rows are required.
Verification / Alternative check:
Run a sample with known unmatched keys and verify that an outer join includes those rows while an inner join filters them out.
Why Other Options Are Wrong:
Common Pitfalls:
Confusing FULL OUTER JOIN with UNION of two separate queries; FULL OUTER JOIN aligns matching keys and only pads unmatched ones with NULLs once.
Final Answer:
Outer join
Discussion & Comments