FOREIGN KEY references same table's column. Can't insert values
问题 I created table with FOREIGN KEY and can't insert anything. CREATE TABLE menus ( id int(10), parent_id int(10), label varchar(255), PRIMARY KEY (id), FOREIGN KEY (parent_id) REFERENCES menus (id) ); I need FOREIGN KEY to automatically delete children when parent was deleted. This table was successfully created but I can't insert anything. INSERT INTO `menus` (`parent_id`, `label`) VALUES ('1', 'label1'); or INSERT INTO `menus` (`label`) VALUES ( 'label1'); #1452 - Cannot add or update a child