views:

71

answers:

3

I have a table with primary key id AUTOINCREMENT and some other attributes.

I have many rows with attribute lang='en'. and I do

DELETE FROM ".MY_PRF."form WHERE `lang` <> 'en'

I want to COPY all them changing lang to 'cz'

I use:

INSERT INTO form (`lang`, `caption`, `type`) 
SELECT 'cz', `caption`, `type` 
FROM form 
WHERE lang = 'en' 

This query produces an error

Duplicate entry '127' for key 1 

I don't know what's happening cause primary key is autoincrement

Please help me to solve my task. thanks.

Again, I want to copy rows with small change, the 'en' rows should remain

A: 

this realy is unlogical you insert an select from same table you have to select from another table

streetparade
It might not be the recommended way to do i18n, but it's not illogical. He's trying to duplicate the contents of the table, but change the language from English to Chinese. Presumably someone is going to translate the text and he is preparing the rows for them.
Mark Byers
ok then he should tell us that and even if that is true for me its unlogical
streetparade
He did say that. Even the original revision of this question states "I want to copy".
ceejayoz
+3  A: 

what is the type of ID variable?

If it is TINYINT change it to the INT

afftee
Good idea - the key=127 error seems to indicate this.
ceejayoz
Oh, guy you are a genius!!!! That was the problem!
Dan
A: 

Why not just update?

UPDATE form SET lang = 'cz' WHERE lang = 'en'

Paul Creasey
I want to copy rows
Dan