I'm trying to have a foreign key (parent_id) and a primary key (id) in an already existing table.
I already used SET FOREIGN_KEY_CHECKS=0; and then I ran this query below but every time I get the same error.
ALTER TABLE categories
ADD CONSTRAINT fk_parent_id FOREIGN KEY ( parent_id ) REFERENCES
categories(id) on DELETE CASCADE
Cannot add or update a child row: a foreign key constraint fails