MySQL Forums
Forum List  »  Performance

Re: Avoid subquery
Posted by: Peter Brawley
Date: May 12, 2015 11:06AM

> I would like to avoid an expensive Subquery

Why assume all subqueries are expensive? In the FROM clause, for example, they're often quick:

SELECT a.father, a.name, a.age 
FROM child as a  
JOIN ( 
  SELECT father, max(age) AS oldest 
  FROM child
  GROUP BY father
) as b ON a.father = b.father and a.age = b.oldest; 

Options: ReplyQuote


Subject
Views
Written By
Posted
1810
May 12, 2015 08:40AM
Re: Avoid subquery
965
May 12, 2015 11:06AM
716
May 12, 2015 01:29PM
681
May 12, 2015 01:41PM
831
May 17, 2015 12:11AM


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.