How to update foreign key value in mysql database

后端 未结 2 1879
盖世英雄少女心
盖世英雄少女心 2020-12-23 18:11

I have three tables: categories, languages and categories_languages. Categories_languages is many to many table which links together categories and languages. I would like t

相关标签:
2条回答
  • 2020-12-23 18:26

    You can temporarily suspend foreign key checking:

    SET foreign_key_checks = 0;
    UPDATE languages SET id='xyz' WHERE id='abc';
    UPDATE categories_languages SET language_id='xyz' WHERE language_id='abc';
    SET foreign_key_checks = 1;
    

    EDIT: As for the foreign key problem: is the data stored on a local or a remote file system? errno 121 is EREMOTEIO (Remote I/O error). Perhaps there are permission problems on the target file system or it doesn't support the # character in filenames?

    0 讨论(0)
  • 2020-12-23 18:45

    If you are looking for a temp solution you can also change the ON UPDATE action to CASCADE and modify your ids

    0 讨论(0)
提交回复
热议问题