List:General Discussion« Previous MessageNext Message »
From:tony Date:July 2 1999 8:31pm
Subject:Re: SELECT WHERE id = MAX(id)
View as plain text  
On Fri, 2 Jul 1999, Martin Ramsch wrote:
>>   SELECT id, amount FROM foo ORDER BY id DESC LIMIT 1;

>SELECT Max(ID) as ID from foo;
>is much faster on a database than the full select with
>the limit 1.

Yes ... but this doesn't return the amount - which is what we want!

I had thought that the DESC limit 1 would have been suboptimal to
a query using MAX(primary key), but it turns out to have been a 
much harder query to create than I had expected ..

Tony
--  
-----------------------------------------------------------------------------
 Tony Bowden | tony@stripped               http://www.blackstar.co.uk/
  Black Star |    The UK's Biggest Video & DVD store * Free Postage Worldwide
-----------------------------------------------------------------------------
Thread
SELECT WHERE id = MAX(id)tony2 Jul
  • Re: SELECT WHERE id = MAX(id)Paul Wolstenholme2 Jul
    • Re: SELECT WHERE id = MAX(id)tony2 Jul
  • Re: SELECT WHERE id = MAX(id)Martin Ramsch2 Jul
    • Re: SELECT WHERE id = MAX(id)Steve Ruby2 Jul
Re: SELECT WHERE id = MAX(id)tony3 Jul
  • Re: SELECT WHERE id = MAX(id)Steve Ruby3 Jul