Re: Can I select only the newest record?

From: Date: Sun, 18 Feb 2001 16:57:15 +0000
Subject: Re: Can I select only the newest record?
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-40441@lists.php.net to get a copy of this message
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

« previous php.general (#40441) next »