RE: [PHP] Can I select only the newest record?
| From: | PHPBeginner.com | Date: | Sun, 18 Feb 2001 17:11:16 +0000 |
| Subject: | RE: [PHP] Can I select only the newest record? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-40448@lists.php.net to get a copy of this message | ||
You're welcome!
Sincerely,
Maxim Maletsky
Founder, Chief Developer
PHPBeginner.com (Where PHP Begins)
maxim@phpbeginner.com
www.phpbeginner.com
-----Original Message-----
From: Brian Drexler [mailto:bdrexler@mail.precisionwd.com]
Sent: Monday, February 19, 2001 1:57 AM
To: creinig@mayn.de; Php-General
Subject: Re: [PHP] Can I select only the newest record?
This worked:
SELECT * from that_table ORDER BY thetimestamp DESC LIMIT 1
Thanks to all for the help.
Brian Drexler
----- Original Message -----
From: Christian Reiniger <creinig@mayn.de>
To: Php-General <php-general@lists.php.net>
Sent: Saturday, February 17, 2001 8:58 AM
Subject: Re: [PHP] Can I select only the newest record?
> On Saturday 17 February 2001 12:12, PHPBeginner.com wrote:
> > 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?
>
> It will you return the id that was used on the last INSERT that *this*
> process (i.e. this script while being executed right now) did.
>
> => it won't help.
>
> > > MySQL table. I have a datetime field and an Auto_incremented field.
>
> If you want the "newest" field, add a timestamp field and do a
> SELECT * from that_table ORDER BY thetimestamp DESC LIMIT 1
>
> a timestamp field in MySQL is by default automatically set to NOW() at
> each INSERT and UPDATE if you don't set it yourself in the query.
>
> --
> Christian Reiniger
> LGDC Webmaster (http://sunsite.dk/lgdc/)
>
> Drink wet cement. Get stoned.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net