R: [PHP-GENERAL] mysq: get the latest row of a table

From: Date: Sat, 24 Jun 2000 15:14:40 +0000
Subject: R: [PHP-GENERAL] mysq: get the latest row of a table
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-2913@lists.php.net to get a copy of this message
Hi Peter, > I've been thinking about this on and off now for a while, is there a fast > way to just get the latest row of a table? Looping through all just seems > like such a waste of time, I'm sure there must be a better way! > Thanks for any hints you can give, > Peter Just order the table descending, and limit your query to 1 row. Example: SELECT name,address FROM addressbook ORDER BY name DESC LIMIT 1; It will return a table of one row. That row will have the last item (ordered by name) of your table. Best Regards, -- Federico Pomi http://www.Pomi.net

« previous php.general (#2913) next »