I wonder, if LAST_INSERT_ID will work in here...
I know it works when on the same file was an insertion.. but will it return
you the last ever inserted id, say a week ago?
I feel like it won't, but don't know for sure... try it...
Sincerely,
Maxim Maletsky
Founder, Chief Developer
PHPBeginner.com (Where PHP Begins)
[EMAIL PROTECTED]
www.phpbeginner.com
-----Original Message-----
From: ..s.c.o.t.t.. [mailto:[EMAIL PROTECTED]]
Sent: Saturday, February 17, 2001 4:59 PM
To: Php-General
Subject: RE: [PHP] Can I select only the newest record?
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]
--
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]