#1062 - Duplicate entry '23933-27243-2' for key 'membersid'

  • basketmen
  • Student
  • Student
  • basketmen
  • Posts: 80

Post 3+ Months Ago

Hi guys,

I have a table, the table name is account,
its have 2 fields : membersid, and categoryid

i want to change the categoryid field content, i run this in phpmyadmin :

update `account` set categoryid = replace (categoryid, '1' , '2');

but get this error message

#1062 - Duplicate entry '23933-27243-0' for key 'membersid'

- what should i do so i can change the field content? Please help.
I already tried changing the field TYPE, from INT, to BIGINT, like other person suggested, but still get that error message

- this is the screenshot from the field Structure

  • gisele
  • Expert
  • Expert
  • User avatar
  • Posts: 585
  • Loc: Nimes (France)

Post 3+ Months Ago


It seems you try to violate a "unique" constraint, you should check "membersid" key definition.
are you sure you have put your key (primary key?) on the right field(s)?
Moreover, you stament looks very strange when applied to integers unless you really want what it will do.
It means :
"I want to repalce every digit =1 by 2 within field values".
For example 12 will change to 22.
wich isn't the same as
update `account` set categoryid = '2' where categoryid = '1';
wich means "if field value = 1 so put 2 instead".

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 34 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum

© 1998-2017. Ozzu® is a registered trademark of Unmelted, LLC.