stevo81989
stevo81989

Reputation: 170

Mysql Returning 'Duplicate Entry' When No Duplicate Exists

Weird issue:

ERROR 1062: 1062: Duplicate entry '21474836476' for key 'twitterid'
SQL Statement:
INSERT INTO `database`.`wp_table` (`id`, `twitterid`) VALUES ('34', '33456305746')

Even though I typed in 33456305746, it thinks I am typing in 21474836476. Now this row does exist already so I tried deleting it and it saves the row with a value of 21474836476. If I remove the unique requirement it saves both rows as 21474836476. Anyone know what in the world is going on here?

Upvotes: 0

Views: 43

Answers (1)

juergen d
juergen d

Reputation: 204766

21474836476 is (close to) the max value of an integer which is the data type of your field.

33456305746 is bigger and the DB truncates the value to the max integer which you already inserted at some time before.

Change the data type of the field to bigint if you need such high numbers.

Upvotes: 4

Related Questions