Re: newbie: mysql statement

From: Date: Mon, 15 Jul 2002 19:05:13 +0000
Subject: Re: newbie: mysql statement
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-107740@lists.php.net to get a copy of this message
On Mon, 15 Jul 2002, Alexander Ross wrote: >I want to update the most recent record (based on the timestamp in field >posted) where the parent field == a specified value (in a table called >header). > >I tried the following mysql statement: > >"UPDATE header WHERE parent = '$this->postid' ORDER by posted SET >parent='$this->parent' LIMIT1"; > >but apparently you can't use ORDER in an UPDATE statement. If I take order >out, the statement works. That being true (and please correct me if its >not) how can I ensure that the newest record is the one being acted upon? >Thanks. By using a where clause to identify the postid in the table, something like this perhaps: UPDATE header SET parent='$this->parent' where postid='$this->postid'; -- ----------------------------------------------------------------------- Greg Donald http://destiney.com/public.key -----------------------------------------------------------------------

« previous php.general (#107740) next »