Consider tables 'UNIFORM' and 'COST':
Uniform
Ucode Uname Ucolor 1 Shirt White 2 Pant Grey 3 T-Shirt Green
Cost
Ucode Size Price 1 L 580 1 M 560 1 S 500 2 L 400 2 M 500
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;
Consider tables 'UNIFORM' and 'COST':
Uniform
| Ucode | Uname | Ucolor |
|---|---|---|
| 1 | Shirt | White |
| 2 | Pant | Grey |
| 3 | T-Shirt | Green |
Cost
| Ucode | Size | Price |
|---|---|---|
| 1 | L | 580 |
| 1 | M | 560 |
| 1 | S | 500 |
| 2 | L | 400 |
| 2 | M | 500 |
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
(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.
Related questions:
2026: 29 May Shift 1
2025: 15 May Shift 2
2026: 13 May Shift 2
2026: 23 May Shift 2