Which of the following can be used as basic approaches for joining tables?
2023
Which of the following can be used as basic approaches for joining tables?
Answer: D. More than one of the above — Concept — the two ways a query reaches a second table. A relational database offers two distinct families of construct for combining data held in different…
- A.
Union JOIN
- B.
Natural JOIN
- C.
Subqueries
- D.
More than one of the above
- E.
None of the above
Attempted by 2453 students.
Show answer & explanation
Correct answer: D
Concept — the two ways a query reaches a second table. A relational database offers two distinct families of construct for combining data held in different tables. A join is a relational operator that takes a row from one table and a row from another and emits a single combined row; the SQL standard defines several such operators. A subquery instead nests one SELECT inside another statement, so the inner query reads the second table and supplies or constrains values for the outer one. Both families are taught as basic approaches for working across tables.
Applying the concept to each named construct
NATURAL JOIN is a join operator. It equi-joins the two tables on every column they share by name and projects each shared column once, so no ON clause is written:
SELECT * FROM emp NATURAL JOIN dept;matches on the commondeptnocolumn.UNION JOIN is also a join operator. SQL-92 introduced it and SQL:2003 withdrew it.
A UNION JOIN Breturns every row of A padded with nulls across B's columns together with every row of B padded with nulls across A's columns, and it never pairs a row of A with a row of B. It coincides with a FULL OUTER JOIN only in the degenerate case where nothing matches at all: wherever rows do match, a FULL OUTER JOIN emits them as one combined row, while UNION JOIN still returns them as two null-padded rows. Very few products ever implemented it, but it is a standardised join type, not an invented term.A subquery is not a join clause, yet it reaches a second table just as effectively:
SELECT ename FROM emp WHERE deptno IN (SELECT deptno FROM dept WHERE loc = 'DALLAS');filters one table using rows read from another, with no JOIN keyword anywhere in the statement.
Cross-check — the three side by side
Construct | Family | Reaches other table by | Result row |
|---|---|---|---|
NATURAL JOIN | Join operator | Implicit equi-join on like-named columns | One row per matched pair |
UNION JOIN | Join operator (SQL-92) | No matching; both tables kept whole | One row per input row, null-padded |
Subquery | Nested query | Inner SELECT supplies or filters values | Rows of the outer table only |
All three named constructs are therefore usable ways of bringing two tables' data together, so no single named construct exhausts what the stem asks for, and the reading that nothing listed qualifies fails as well. The answer is More than one of the above.
Common confusion. UNION JOIN is not a misprint for the UNION set operator. UNION stacks two result sets vertically and requires union-compatible column lists; UNION JOIN widens the row instead, placing the two tables’ columns side by side and null-padding whichever side a given row did not come from.