d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Mysql > Need Help
Add Reply New Topic New Poll
Member
Posts: 10,006
Joined: Nov 3 2013
Gold: 12,096.27
Feb 1 2016 04:27am
MySQL Error!
------------------------

The Error returned was:
Duplicate entry '8388607' for key 'PRIMARY'

Error Number:
1062

INSERT INTO dle_views (news_id,addtime) VALUES ('1229440','1454319919')


how to fix this probem can someone help me? will pay fg ofc

also how i can check my mysql version
how i can go into code lines in mysql

fg for help
Member
Posts: 10,415
Joined: Aug 24 2005
Gold: 24,533.60
Feb 1 2016 04:39am
try to extract the duplicated record

SELECT * from dle_views WHERE news_id = *IDVALUE*

when you get values you can run some test and try tu run UPDATE query on this record



another method (i dont like this)

you can try to force insert by ignoring errors (at your own risk) just adding IGNORE in your query

INSERT IGNORE INTO dle_views (news_id,addtime) VALUES ('1229440','1454319919')

This post was edited by EoN-mf on Feb 1 2016 04:40am
Member
Posts: 1,158
Joined: Oct 5 2010
Gold: 0.00
Mar 6 2016 05:15am
You've got a unique id constraint on a primary ID column.

It should be set to "autoinc" so you can insert records without providing a value for it.

If you haven't got an autoinc set, then you need to provide the ID in your insert statement, which im guessing you did not do, since the ID in the error does not match either or your values.
This indicates your current next index / default was corrupted and it's trying to set a value you've already got in the index table.

You can manually open the table in design mode, select * from tablename where id >= the error value in question and if needed reassign it.
Member
Posts: 161,550
Joined: Oct 18 2006
Gold: 4.03
Warn: 20%
Mar 7 2016 02:49am
Quote (Hamada @ Feb 1 2016 03:27am)
MySQL Error!
------------------------

The Error returned was:
Duplicate entry '8388607' for key 'PRIMARY'

Error Number:
1062

INSERT INTO dle_views (news_id,addtime) VALUES ('1229440','1454319919')


how to fix this probem can someone help me? will pay fg ofc

also how i can check my mysql version
how i can go into code lines in mysql

fg for help


either select and find your same value as #2 said or UPDATE the value with your new non primary key information with a: WHERE id = 'primarykeythatyougotaduplicateof'


SELECT VERSION(); for version
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll