Comments on: How to avoid unique index violations on updates in MySQL http://www.xaprb.com/blog/2006/06/16/how-to-avoid-unique-index-violations-on-updates-in-mysql/ Stay curious! Fri, 10 May 2013 13:48:52 +0000 hourly 1 http://wordpress.org/?v=3.5.1 By: Devon Yates http://www.xaprb.com/blog/2006/06/16/how-to-avoid-unique-index-violations-on-updates-in-mysql/#comment-14644 Devon Yates Fri, 23 May 2008 16:28:27 +0000 http://www.xaprb.com/blog/?p=165#comment-14644 Hi,
This is an interesting topic. Thanks for documenting it. I was wondering if you ever followed up with the post on the concept of swapping rows. I have just run into a situation where I have a unique index, where one of the values within the unique index has swapped. What is the easiest/best way to handle this?
Cheers,
Devon Yates

]]>
By: Xaprb http://www.xaprb.com/blog/2006/06/16/how-to-avoid-unique-index-violations-on-updates-in-mysql/#comment-4049 Xaprb Mon, 12 Feb 2007 14:18:30 +0000 http://www.xaprb.com/blog/?p=165#comment-4049 It looks like you might accidentally be trying to update the idCalendarEntry column — are you sure the query is being issued as you say? If so, that’s pretty bizarre.

]]>
By: Simon Giddings http://www.xaprb.com/blog/2006/06/16/how-to-avoid-unique-index-violations-on-updates-in-mysql/#comment-4048 Simon Giddings Mon, 12 Feb 2007 14:05:32 +0000 http://www.xaprb.com/blog/?p=165#comment-4048 Hi,

I issue an update statement containing a where clause on the primary
index, so as to update a single record. Howerver this is failing with
“Duplicate entry ’6′ for key 1″ -
update clients.calendarentry set Subject = ‘presentation’ where
idCalendarEntry = 6;

In the table, the field ‘idCalendarEntry’ is declared as :
`idCalendarEntry` int(10) unsigned NOT NULL auto_increment

The server version of MySql I am using is 5.0.24
The client version of MySql I am using is 5.0.11

Are you able to help?
Simon

]]>
By: Mark http://www.xaprb.com/blog/2006/06/16/how-to-avoid-unique-index-violations-on-updates-in-mysql/#comment-1715 Mark Wed, 06 Sep 2006 21:22:43 +0000 http://www.xaprb.com/blog/?p=165#comment-1715 I was working on a project and ran into this exact problem, fortunately a google search turned up your article and it saved me. Thanks for the assist!

]]>
By: Noah Winecoff http://www.xaprb.com/blog/2006/06/16/how-to-avoid-unique-index-violations-on-updates-in-mysql/#comment-960 Noah Winecoff Wed, 21 Jun 2006 16:02:34 +0000 http://www.xaprb.com/blog/?p=165#comment-960 Great write up. I develop everyday using MySQL and information like this makes my job a lot easier. Thanks.

]]>