Skip to main contentSkip to solution

Consider tables 'UNIFORM' and 'COST':

Uniform

UcodeUnameUcolor
1ShirtWhite
2PantGrey
3T-ShirtGreen

Cost

UcodeSizePrice
1L580
1M560
1S500
2L400
2M500

Which of the following are correct commands to display the records from both the tables?

(A) SELECT * FROM UNIFORM U JOIN COST C WHERE U.UCode = C.UCode;

(B) SELECT * FROM UNIFORM U, COST C WHERE U.UCode = C.UCode;

(C) SELECT * FROM UNIFORM U JOIN COST C ON U.Ucode=C.Ucode;

(D) SELECT * FROM UNIFORM NATURAL JOIN COST;

Solution

✅ Correct Option: 2

(B) uses a comma join (Cartesian product) filtered by the WHERE condition. (C) uses JOIN with an ON clause. (D) uses NATURAL JOIN, which automatically joins on the common column Ucode. All three give the same matching records from both tables.


(A): in standard SQL, JOIN must be followed by an ON (or USING) clause. Writing the condition in WHERE after a plain JOIN is a syntax error.

Natural join keeps only one Ucode column in the output, while (B) and (C) show Ucode from both tables, but the matched rows are the same.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question