there are two ways that come to mind of doing this if you're
using some kind of auto-incrementing field (not necessarily
AUTO_INCREMENT, but any field that increases [or decreases]
with time)
this will select the entire row, but limit the query to only
return 1 result (and depending on how your order, this
result could be the highest/lowest value of the field):
(to get highest value of field id)
SELECT * FROM mytable ORDER BY id ASC LIMIT 1;
(to get lowest value of field id)
SELECT * FROM mytable ORDER BY id DESC LIMIT 1;
PS: there's probably a more efficient way to do it,
but this is what came to mind at the moment...
> -----Original Message-----
> From: Brian Drexler [mailto:[EMAIL PROTECTED]]
> Sent: Friday, February 16, 2001 20:22
> To: Php-General
> Subject: [PHP] Can I select only the newest record?
>
>
> Using PHP3/MySQL, is there a way I can select only the newest record from a
> MySQL table. I have a datetime field and an Auto_incremented field. Anyone
> got any ideas???
>
> Brian Drexler
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]