Re: Can I select only the newest record?

From: Date: Sat, 17 Feb 2001 13:58:43 +0000
Subject: Re: Can I select only the newest record?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-40328@lists.php.net to get a copy of this message
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.

« previous php.general (#40328) next »