Skip to content

ISRO Scientist/Engineer CSE 2020Databases › SQL

ISRO Scientist/Engineer CSE 2020 PYQ: The SQL query SELECT columns FROM TableA RIGHT OUTER JOIN TableB ON A.columnName = B.columnName WHERE…

The SQL query

SELECT columns
FROM TableA
RIGHT OUTER JOIN TableB
ON A.columnName = B.columnName
WHERE A.columnName IS NULL

returns the following:

  1. A
    All rows in Table $\text{B}$ , which meets equality condition above and, none from Table $\text{A}$ which meets the condition.
    Correct answer
  2. B
    All rows in Table $\text{A}$ , which meets equality condition above and none from Table $\text{B}$ , which meets the condition.
  3. C
    All rows in Table $\text{B}$ , which meets the equality condition
  4. D
    All rows in Table $\text{A}$ , which meets the equality condition

Answer

(A) All rows in Table $\text{B}$ , which meets equality condition above and, none from Table $\text{A}$ which meets the condition.

Approach

A RIGHT OUTER JOIN preserves every row of the right table (Table B) and attaches matching rows from the left table (Table A). For any B row that has no partner in A, the join condition A.columnName = B.columnName is never true, so all A-side columns are filled with NULL in the joined result. The WHERE clause A.columnName IS NULL then keeps exactly those rows — the ones where no A row matched. This is the classic 'anti-join' pattern. The result therefore consists of all rows of Table B that have no counterpart in Table A; it contains no contributing rows from Table A, since wherever an A row did match, A.columnName is non-NULL and is filtered out. Among the choices, only option A captures this: it states that all rows from Table B are returned and none from Table A that meet the condition. Options B and D are wrong immediately because a RIGHT OUTER JOIN cannot produce 'all rows in Table A'; option C is wrong because it omits the IS NULL filter entirely and would describe a plain RIGHT OUTER JOIN (B rows that DO match), which is not what the WHERE clause yields. Although option A's wording is awkward and the phrase 'which meets equality condition above' is loosely placed, its intended reading — all rows in Table B, and none from Table A that meet the equality condition — matches the semantic of the query (an anti-join that returns B rows lacking an A match). No other option is even remotely consistent with the query, so A is the definitive intended answer.

Reviewed by ISRO IQ Editorial Team.