Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Which query would be more efficient? 1 . SELECT * FROM customer WHERE city IN ( SELECT city FROM employee WHERE reports _ to =

Which query would be more efficient?
1. SELECT *
FROM customer
WHERE city IN
(SELECT city
FROM employee
WHERE reports_to =2);
2. SELECT customer.*
FROM customer
INNER JOIN employee
ON customer.city = employee.city
WHERE reports_to =2;
Query #2 would be more efficient as it is based on primary and foreign keys.
Both would be the same as both use the same indices for the join and filter.
Query #1 would be more efficient as it is based on primary and foreign keys.
Query #1 would be more efficient as it is not using indexed columns.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

How would you handle this situation?

Answered: 1 week ago

Question

Understanding Groups

Answered: 1 week ago