MySQL Forums
Forum List  »  Newbie

Re: Mystery query
Posted by: Phillip Ward
Date: November 07, 2013 06:58AM

Because MySQL is having to run three queries in series:
(1) select from order_details, based no Product Id, then
(2) select from orders, based on Order Id , then
(3) select from customers, based on Customer Id.
Even with proper indexing, there's no way MySQL can evaluate that query any other way.

This might be a little better, playing to MySQl's strengths:

   select c.CompanyName 
   ,      c.City 
   ,      c.Country
   from       customers c 
   inner join order o 
           on c.CustomerId = o.customerid 
   inner join order_details od 
           on o.OrderId = od.OrderId 
   where od.ProductId = 34 ;

Regards, Phill W.

Options: ReplyQuote


Subject
Written By
Posted
November 06, 2013 12:19AM
Re: Mystery query
November 07, 2013 06:58AM
November 07, 2013 07:22PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.