On other two tables, I have set foreign to d_desavanja->id field, but on this table, I can’t.
How can I make it works?
SQL query:
ALTER TABLE `d_des_kat` ADD FOREIGN KEY ( `desavanje_id` ) REFERENCES `desavanja`.`d_desavanja` (
`id`
) ON DELETE CASCADE ON UPDATE CASCADE ;
MySQL said:
#1452 - Cannot add or update a child row: a foreign key constraint fails (`desavanja/#sql-12f3_5af2e`, CONSTRAINT `#sql-12f3_5af2e_ibfk_1` FOREIGN KEY (`desavanje_id`) REFERENCES `d_desavanja` (`id`) ON DELETE CASCADE ON UPDATE CASCADE)
You’ve got a row in
d_des_katthat fails the constraint. Check your data to make sure that all non-NULLd_des_kat.desavanje_idvalues match an existingidind_desavanja.The following query should show you the offending rows: