RE: [PHP] newbie: mysql statement

From: Date: Mon, 15 Jul 2002 19:18:29 +0000
Subject: RE: [PHP] newbie: mysql statement
Groups: php.general 
Request: Send a blank email to php-general+get-107743@lists.php.net to get a copy of this message
If you could retrieve the max(posted) prior to doing the update you could; SELECT max(posted) from header WHERE parent = '$this->postid' and substitute the value in the following query; Update header SET parent='$this->parent' WHERE parent = '$this->postid' AND posted = $retrieved_posted A subselect would work great here by not in MySQL. Warren Vail Tools, Metrics & Quality Processes (415) 667-7814 Pager (877) 774-9891 215 Fremont 02-658 -----Original Message----- From: Alexander Ross [mailto:alexross@bleen.net] Sent: Monday, July 15, 2002 11:56 AM To: php-general@lists.php.net Subject: [PHP] newbie: mysql statement 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. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#107743) next »