Re: newbie: mysql statement
| From: | Martin Clifford | Date: | Mon, 15 Jul 2002 19:11:00 +0000 |
| Subject: | Re: newbie: mysql statement | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-107742@lists.php.net to get a copy of this message | ||
I would rewrite the query as:
"UPDATE header SET parent='$this->parent' WHERE max(posted) = max(posted)"
I would think this to work, though I don't have the facilities to test it, and have never
needed to do a query such as this. In theory, it should update ONLY the row where the maximum value
of the posted column equals itself, thereby being the latest date. Just an idea.
Martin Clifford
Homepage: http://www.completesource.net
Developer's Forums: http://www.completesource.net/forums/
>>> "Alexander Ross" <alexross@bleen.net> 07/15/02 02:56PM >>>
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