views:

54

answers:

3

I am not sure why I am getting this error #1062 - Duplicate entry '1' for key 1 cany any one help explain what it means. Thanks

+2  A: 

More than likely your column is set to be Unique, and you're trying to input a row with an ID that already exists in your table.

bradenkeith
How would i fix that?
Webne
Setting the column to auto_increment and not inserting a value when inserting the row (letting it auto populate) would be the best fix. Or you could see the last ID in your table though, and increment it by one for your value.
bradenkeith
+3  A: 

You are probably trying to insert a record with the ID (or some other field) 1 set, while such a record already exists in the table. The field that is the primary key must have a unique value for each record.

Pekka
+1: Primary key is the first suspect; unique key is second...
OMG Ponies
I am doing a drupal to wordpress conversion and when I get to this part of the conversionINSERT INTO lceating_wrdp1.wp_terms (term_id, `name`, slug, term_group)SELECT d.tid, d.name, REPLACE(LOWER(d.name), ' ', '-'), 0FROM wrdp1.term_data dINNER JOIN wrdp1.term_hierarchy h USING(tid) it throws this error #1062 - Duplicate entry '1' for key 1I set the primary key to be unique.
Webne
@Webne you may have to set the key back to non-unique for the first import, or unset the IDs in the table you're copying from. Whether that is safe to do is impossible to tell without knowing the data.
Pekka
+1  A: 

I think you're trying to insert '1' to a unique key field that already has a '1' value

eiefai
I am doing a drupal to wordpress conversion should i do a drop the table content and then try again?
Webne
I honestly don't know
eiefai
Hate to ask another question but, I dropped the table and started from scratch I am not getting the duplicate any more but I am getting this error #1062 - Duplicate entry 'lc-plans' for key 2 does that mean that I am trying to add two of the 'lc-plans' field?thanks
Webne
yes, the error you are getting its the same (#1062) but in a different field, you shouls check the db schema of wordpress (constraints, primary keys, unique keys, etc.) before trying to insert data.
eiefai