I'm trying to add a foreign key to an already existing table called OrdersTbl. I added a new column called ApprovedBy like so:
ALTER TABLE OrdersTbl ADD ApprovedBy BIGINT UNSIGNED NOT NULL;
After that, I tried setting it as the foreign key:
ALTER TABLE OrdersTbl
ADD CONSTRAINT ApprovedByEmp FOREIGN KEY (ApprovedBy)
REFERENCES EmployeesTbl(EmployeeID);
But I keep getting
Error 1452: Cannot add or update child row
What am I doing wrong? Should I have set the field ApprovedBy
as FOREIGN KEY instead?