IAE Academy

ISRO CS 2023 Q.31: solution and answer

ISRO 2023 · CSQ.31 · 1 mark · MCQ

In SQL the statement select * from R, S is equivalent to

  1. (A)

    Select * from R natural join S

  2. (B)

    Select * from R cross join S

  3. (C)

    Select * from R outer join S

  4. (D)

    Select * from R inner join S

See the question in the paper

Answer and solution

ANSWER

The statement is equivalent to select * from R cross join S, which is option (B).

Official answer: BSource: ISRO's revised and final answer key of 16 February 2024

  1. Listing two tables in the FROM clause separated by a comma, with no WHERE condition, forms their Cartesian product: every row of R is paired with every row of S.

  2. If R has rows and S has rows, the result has rows and contains the columns of both tables.

  3. CROSS JOIN is defined as exactly this Cartesian product, so select * from R, S is equivalent to select * from R cross join S.

  4. Option A is wrong: a natural join pairs rows only where all common attribute names have equal values and keeps one copy of each such column, so it returns only the matching pairs.

  5. Option C is wrong: an outer join keeps the matching pairs and also pads unmatched rows with nulls, so it is not a plain product.

  6. Option D is wrong: an inner join keeps only the pairs that satisfy a join condition, so it filters rows, while the comma form filters nothing.

KEY IDEA

A comma-separated list of tables in FROM with no condition is the Cartesian product, which is what CROSS JOIN means.

WATCH OUT FOR

Choosing inner join because the comma form is often paired with a WHERE condition. Without that condition nothing is filtered, so it is a cross join, not an inner join.

From the ISRO CS 2023 paper. Every question of this paper · The full paper (PDF, ISRO) · All 4 ISRO SQL questions, with notes

More ISRO SQL questions