45.6k views
1 vote
Structure of the PROMOTION table

Structure of the BOOKS table​
Structure of the ORDERITEMS table
Which of the following SQL statements will display the gift or gifts that should be sent with order# 1003?​
a) SELECT p.gift FROM PROMOTION p JOIN ORDERITEMS oi ON p.promotion_id = oi.promotion_id WHERE oi.order_number = 1003;

b) SELECT gift FROM PROMOTION WHERE order_number = 1003;

c) SELECT gift FROM ORDERITEMS WHERE order_number = 1003;

d) SELECT gift FROM PROMOTION WHERE promotion_id = 1003;

User C Panda
by
7.4k points

1 Answer

6 votes

Final answer:

The correct SQL statement to display the gift or gifts for order #1003 is option a) which joins the PROMOTION and ORDERITEMS tables on the promotion_id and filters the result by the order number.

Step-by-step explanation:

To display the gift or gifts that should be sent with order #1003, you need to select the appropriate records from the PROMOTION table that relate to this order number through the ORDERITEMS table. The correct SQL statement would join these two tables on the promotion_id, filter the records by order number, and select the gift column from the PROMOTION table. Therefore, the appropriate SQL statement is:

a) SELECT p.gift FROM PROMOTION p JOIN ORDERITEMS oi ON p.promotion_id = oi.promotion_id WHERE oi.order_number = 1003;

This statement will retrieve all gifts associated with order #1003 by joining the PROMOTION and ORDERITEMS tables on the common promotion_id field and filtering the results to only include those related to the specified order number.

User Matan Shahar
by
6.8k points