List:General Discussion« Previous MessageNext Message »
From:Fraser MacKenzie Date:April 29 1999 12:02pm
Subject:Select most recent row - another one for the FAQ perhaps?
View as plain text  
True.  I didn't notice that he wanted more than just the latest back.  Why
not use an order by with a limit of 1?  If you use ASC or DESC you can
determine the first or the last.

Fraser

On Thu, 29 Apr 1999, Fred Read wrote:

> Fraser MacKenzie wrote:
> > 
> > Sure you can do this.  I do it all the time.  Here is the select
> > 
> > select MAX(latest) from MyTable where username='MyUsername';
> 
> Ok, but the question was;
> 
>     "How do I return the most recent row for a given xxx?"
> 
> With your solution I would have to do two selects;
> 
>  1. Find Max(Date) for UserName
>  2. Select row for UserName AND [previously found] Max(Date)
> 
> This is not an atomic operation so unless tables are locked, 
> could result in data inconsistencies...
> -- 
> 
> If it ain't opinionated, it ain't Rich Teer.
> 

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