MySQL INSERT SELECT problem
I have a table with primary key id AUTOINCREMENT
and many columns where lang='en'
and so if I do:
D开发者_Go百科ELETE FROM ".MY_PRF."form WHERE `lang` <> 'en';
I want to copy all the columns where lang='en'
and then changing lang
to 'cz'
like so:
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 because the primary key is AUTOINCREMENT
. I just want to duplicate the lang='en'
rows changing the lang
to 'cz'
.
what is the type of ID variable?
If it is TINYINT change it to the INT
精彩评论