MySQL Forums
Forum List  »  Stored Procedures

Re: how to Replace subquery's with join(min,max)
Posted by: Thomas Wiedmann
Date: May 10, 2011 12:01PM

try this..

/* first */
SELECT t1.* 
  FROM table1 t1 
  JOIN ( SELECT MAX(t2.id) AS max_id FROM table1 t2 ) t2
    ON t1.id = t2.max_id;
    
/* second */
SELECT * FROM table1
ORDER BY id DESC
LIMIT 1;

with kind regards,
Thomas

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: how to Replace subquery's with join(min,max)
1528
May 10, 2011 12:01PM


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.