RE: [PHP-DB] Spot the deliberate mistake...
| From: | Norland, Martin | Date: | Thu, 16 Dec 2004 18:00:41 +0000 |
| Subject: | RE: [PHP-DB] Spot the deliberate mistake... | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-37721@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Mark Benson [mailto:markbenson@mac.com]
> If I try that it returns:
> You have an error in your SQL syntax near 'ON DUPLICATE KEY UPDATE' at
line 1
> so I guess something doesn't work there. I also tried it with and
without the line ending and it didn't work either way :).
Are you running a version of mysql >= 4.1.0 ?
"If you specify the ON DUPLICATE KEY UPDATE clause (new in MySQL 4.1.0),
and a row is inserted that would cause a duplicate value in a UNIQUE
index or PRIMARY KEY, an UPDATE of the old row is performed."
http://dev.mysql.com/doc/mysql/en/INSERT.html
Also, note - I was VERY WRONG! You are allowed to follow the statement
with what you want updated - and I believe you're supposed to. I
knee-jerked that first answer, assuming it must be it since the
information was so redundant - my apologies. I expect, however, that
you're not supposed to specify the key again with the update part,
though I suppose it's possible to.
Cheers,
- Martin Norland, Database / Web Developer, International Outreach x3257
The opinion(s) contained within this email do not necessarily represent
those of St. Jude Children's Research Hospital.