I have this scheme for tables
And i can't insert any value into a second or 3d table at all becouse of error 1452 (cannot add or update a child row.) How can i insert something? (not useing a SET FOREIGN_KEY_CHECKS=0;)
I have this scheme for tables
And i can't insert any value into a second or 3d table at all becouse of error 1452 (cannot add or update a child row.) How can i insert something? (not useing a SET FOREIGN_KEY_CHECKS=0;)
Copyright © 2021 Jogjafile Inc.
If you have cyclic foreign keys reference than you cannot insert data directly - insertion into any table fails due to foreign key violation, and insertion in more than one table per one query not supported.
The solution: insert into first table but set referencing column to NULL, insert into second table, update first table.
Example:
db<>fiddle here