13.5k views
3 votes
Which of the following is a valid SQL statement? a. c.customer#, order#, orderdate, shipdate FROM customers c NATURAL JOIN orders c; b. * FROM customers JOIN orders ON (customer#); c. c.customer#, order#, orderdate, shipdate FROM customers c, orders c WHERE c.customer# = o.customer#; d. both b and c

User Markie
by
6.0k points

1 Answer

4 votes

Options A and C are valid SQL statements as JOIN is a JOIN clause that generate an implicit join based on the common columns in both tables.

a. c.customer#, order#, orderdate, shipdate FROM customers c NATURAL JOIN orders c;

c. c.customer#, order#, orderdate, shipdate FROM customers c, orders c WHERE c.customer# = o.customer#;

Step-by-step explanation:

In option A, there is an explicit join created between source table(customers) and the target table(orders) thus displaying the required data field names.

Option B is a JOIN clause with an ON clause. However, end-user can use the ON clause will have to be used only when there is more than one common column in both the tables.

Option C is the standard SQL statement using the WHERE clause based on the condition. Both A and C will return the same query output.

User Alex McLean
by
6.8k points