MySQL Forums
Forum List  »  InnoDB

Re: Left Join, Subselect and Limit
Posted by: Ben Einstein
Date: April 21, 2008 12:41PM

After playing around a bit, I've figured out a very complex work around. It's a double subquery:

"SELECT SomeFields... FROM CD
LEFT JOIN
(SELECT SomeOtherFields... FROM Transaction JOIN
(SELECT MAX(Transaction.Date) AS MaxDate, Transaction_CD_fk FROM Transaction WHERE SomeConditions.... GROUP BY Transaction_CD_fk) AS TransactionMax
ON CD_pk = TransactionMax.Transaction_CD_fk AND Transaction.Date = TransactionMax. MaxDate) AS TransactionSubquery
ON CD.CD_pk = TransactionSubquery.Transaction_cd_fk"

It's insanely ugly, but it works.

Is there a better way to do this?

Options: ReplyQuote


Subject
Views
Written By
Posted
29668
April 21, 2008 09:05AM
Re: Left Join, Subselect and Limit
13967
April 21, 2008 12:41PM


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.