MySQL Forums
Forum List  »  Newbie

Error Code 1062 Duplicate Primary Key
Posted by: Karen Ledin
Date: November 24, 2018 11:03AM

Hi! I have been working on this for awhile. This is the table:

CREATE TABLE pres_term
term_start_date DATETIME(6),
term_end_date DATETIME(6),
number_of_elections_won INT(10),
reason_for_leaving_office CHAR(25),
PRIMARY KEY (pres_id)
) ;

This is the original script to insert data: (just the first 3 or so rows - there are quite a few)

Insert into pres_term values ( 1, '1789-07-01', '1797-03-04', 2,
'Did not seek re-election', NUll);
Insert into pres_term values ( 2, '1797-03-04', '1801-03-04', 1,
'Lost reelection', null);
Insert into pres_term values ( 3, '1801-03-04', '1809-03-04', 2,
'Did not seek reelection', null);

With the above I get: Error Code: 1136. Column count doesn't match value count at row 1

I remove Null and that seemed to work for that Error but then I get Error Code: 1062. Duplicate entry '1' for key 'PRIMARY'

I have tried a number of things to fix it and I keep getting the same thing. What am I doing wrong? Thank you.

Options: ReplyQuote

Written By
Error Code 1062 Duplicate Primary Key
November 24, 2018 11:03AM

Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.