Question

I have a table with primary key id AUTOINCREMENT and many columns where lang='en' and so if I do:

DELETE 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'.

Was it helpful?

Solution

what is the type of ID variable?

If it is TINYINT change it to the INT

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top