Mysql Duplicate entry error on ON DUPLICATE KEY UPDATE -
I am using a memory table There are several IDs in it and the counter is all data integer My code updates counter from 1 if the data is present or creates a line with counter = 1, not so.
The query I use is:
INSERT INTO link_mem (id1 id2, id31, id4 cnt) values (31316, 0, 557,158,967, 261,470594, 1) The key update on the duplicate cnt = cnt + 1
Sometimes (about 5%) I 'Duplicate Entry' for Key Key [Key Number] ''
What could be the problem? Is there such a duplicate key update that handles the duplicate key?
UPDATE: Creating table of
add CREATE TABLE `linked_mem` (` li_sid` integer (10) unsigned NULL default '0', `li_id1` integer (10) unsigned NULL default '0', `li_cid1` integer (10) unsigned NULL default '0',` li_id2` integer (10) unsigned NULL default '0', `li_cid2` integer (10) unsigned NULL default '0', `cnt` et (10) unsigned not tap default '1',` li_filter` int (10) unsigned zero The default '0', `li_group` int (10) is not unsigned, zero defau lt '0', primary key (` li_id1`, `li_sid`,` li_cid1`, `li_cid2`,` li_group`, `cnt`,` li_id2 `)) Engine = memory default charset = latin1
This can happen if you have a Update code that is marked as UNIQUE
and another key UPDATE
at
Update : < / P>
The infringement occurs. I can see that this is actually your case.
This is the reason why:
enter linked_mem (ID1 id2, id31, id4 cnt) (31316, 0, 557,158,967, 261,470, 594, 1) - Insert insertion into linked_mem values (ID1 id2, id31, id4 cnt) values (31316, 0, 557,158,967, 261,470594, 1) - Update `linked_mem (ID1 ID2, id31, id4 cnt) values (31316, 0, 557,158,967 check 2) To insert 'cnt`, 261470594, 1) - again try to update `cnt` and fails
your primary key cnt
from the definition.
Comments
Post a Comment