Question: Consider the following queries: 1 . SELECT * FROM invoice WHERE customer _ id IN ( SELECT customer _ id FROM customer WHERE first _

Consider the following queries:
1. SELECT * FROM invoice
WHERE customer_id IN
(SELECT customer_id FROM customer
WHERE first_name like 'J%');
2. SELECT invoice.* FROM invoice
INNER JOIN customer
ON customer.customer_id = invoice.customer_id
WHERE first_name like 'J%';
Which of these would be the most efficient?
a.)
Query #2 would be more efficient, as it is based on the primary key and foreign keys.
b.)
Query #1 would be more efficient, as it is based on the primary key and foreign keys.
c.)
Both would be the same, as both use the same indices for the join and filter.
d.)
Query #2 would be more efficient, as it is not using indexed columns.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!