List:General Discussion« Previous MessageNext Message »
From:Michael Longval Date:May 1 1999 3:33am
Subject:Re: Select most recent row - another one for the FAQ perhaps?
View as plain text  
This was a recent thread about ordering by most recent.

I tried it and it works.

But how would I do it if I wanted the 1 most recent record from 3 or 4
tables, using search criteria in each case, then combined into a join.

Michael J. Longval, M.D.

==================================
 

On Thu, 29 Apr 1999, Fred Read wrote:

> Erik Liljencrantz wrote:
> > 
> > Maybe I'm missing something, but;
> >     "order by fieldname desc limit 1" usually
> > gets me the record where the field has the largest value (or 
> > smallest without desc).
> > 
> > In this case:
> >   select UserName, Created
> >     from MyTable
> >     where UserName = 'MyUserName'
> >     order by Created desc limit 1
> > 
> > To simple to work? mySQL knows how to optimize this type of query.
> 
> Ah! [Slaps hand to forehead loudly!]
> 
> Thanks, that ought to do it...
> -- 
> 
> If it ain't opinionated, it ain't Rich Teer.
> 
> ---------------------------------------------------------------------
> Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before
> posting. To request this thread, e-mail mysql-thread2607@stripped
> 
> To unsubscribe, send a message to the address shown in the
> List-Unsubscribe header of this message. If you cannot see it,
> e-mail mysql-unsubscribe@stripped instead.
> 

Thread
Select most recent row - another one for the FAQ perhaps?Fred Read29 Apr
  • Re: Select most recent row - another one for the FAQ perhaps?Robin Bowes29 Apr
  • Re: Select most recent row - another one for the FAQ perhaps?Fred Read29 Apr
  • Re: Select most recent row - another one for the FAQ perhaps?Robin Bowes29 Apr
  • Re: Select most recent row - another one for the FAQ perhaps?Christian Mack29 Apr
    • Re: Select most recent row - another one for the FAQ perhaps?Fraser MacKenzie29 Apr
      • Re: Select most recent row - another one for the FAQ perhaps?Fred Read29 Apr
        • Select most recent row - another one for the FAQ perhaps?Fraser MacKenzie29 Apr
    • Re: Select most recent row - another one for the FAQ perhaps?Erik Liljencrantz29 Apr
  • Re: Select most recent row - another one for the FAQ perhaps?Fred Read29 Apr
    • Re: Select most recent row - another one for the FAQ perhaps?Michael Longval1 May
      • Re: Select most recent row - another one for the FAQ perhaps?Thimble Smith1 May
  • Re: Select most recent row - another one for the FAQ perhaps?Robin Bowes29 Apr
    • Re: Select most recent row - another one for the FAQ perhaps?Erik Liljencrantz29 Apr
      • Re: Select most recent row - another one for the FAQ perhaps?Michael Widenius30 Apr