DELETE of 2 dependent tables does not work (MariaDB)

A

Anonymous

Guest
Hello,

I have two tables with a foreign key in the child table (sections : cpicks / 1: n)

I tried to delete section entries and dependent cpicks entries like that:

$query = "DELETE sections,cpicks FROM sections INNER JOIN cpicks ON cpicks.section_id = sections.id WHERE sections.id = ".$sectionID."";

However I still receive this message:

Unable to execute query. Cannot delete or update a parent row: a foreign key constraint fails (`cherrypics-3133335250`.`cpicks`, CONSTRAINT `cpicks_ibfk_1` FOREIGN KEY (`section_id`) REFERENCES `sections` (`id`))

What is the reason here? Thanks.
 
That's the whole point of using foreign keys, if you don't want or need them, don't use them.
 
hyper said:
That's the whole point of using foreign keys, if you don't want or need them, don't use them.

O.k., I understand, thanks!
 
Back
Top