473,511 Members | 17,577 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ON DUPLICATE KEY UPDATE with an old version of MySQL

ON DUPLICATE KEY UPDATE is new as of MySQL 4.1.0, but the web server
that I'm using has MySQL 4.0.24

How would I implement ON DUPLICATE KEY UPDATE with an old version of
MySQL?

Thank you,
Alec Colvin

Sep 25 '05 #1
1 2312
>ON DUPLICATE KEY UPDATE is new as of MySQL 4.1.0, but the web server
that I'm using has MySQL 4.0.24

How would I implement ON DUPLICATE KEY UPDATE with an old version of
MySQL?


Attempt an insert. If it fails due to a duplicate key error, do the
update. Oh, yes, to really mimic the behavior you need to put locks
around the two queries to prevent something else from deleting
the record in between the two.

Gordon L. Burditt
Sep 26 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
16408
by: jtw | last post by:
I need to update a statistics table through out the day. I would like to insert the first data sampling of the data, then update the existing record for the rest of the day. The problem is that I...
1
838
by: Gary Lundquest | last post by:
It appears to me that MySQL version 4 returns an error messge when doing an Insert that results in duplicate entries. Version 3 did NOT return an error - it dropped the duplicate entries and ran...
1
2955
by: JStrummer | last post by:
I just put together a PHP mailing list sign-up page that posts to a mySQL DB. The PHP script prevents INSERTs when the email address is already located in the database. Problem: I need to import...
2
4468
by: Eduardo Pérez Ureta | last post by:
How may I do a INSERT ON DUPLICATE KEY UPDATE like in mysql: http://dev.mysql.com/doc/mysql/en/INSERT.html ? Eduardo ---------------------------(end of broadcast)---------------------------...
8
9457
by: Nick | last post by:
I have a table with columns (product_id,related_product_id,related_counter) If product A is related to product B then a record should be created, if the record already exists then the...
0
1905
by: phillip.s.powell | last post by:
CREATE TABLE /*! IF NOT EXISTS */ blah SELECT * FROM blah1 ON DUPLICATE KEY UPDATE unique_key=unique_key UNION SELECT * FROM blah2 ON DUPLICATE KEY UPDATE unique_key=unique_key TYPE=MyISAM ...
0
2061
by: Donius | last post by:
Hello team. I'm running mysql 4.0.20-standard and i'm trying to do a query like this: INSERT IGNORE INTO `DonorPledges` ( nDonor_id, nPledgeYear, nTotalPaid, nTotalPledge ) SELECT
7
9765
by: Jon Maz | last post by:
Hi, I have a MySql problem I hope someone can help me with. I'm trying to run an update on a linking table, the update is running into a Primary Key constraint violation, and in my workaround...
7
2895
by: php_mysql_beginer911 | last post by:
Hi .. i am trying to update a table where if field contents any duplictaed entries than one of the field should be updated with random number which is unique so i can make all entries unique i...
0
7245
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7144
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7356
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7427
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7512
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5069
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3214
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
785
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
449
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.