I am trying to create a series of tables using Foreign Keys of Primary Keys from other tables, however I always get the error
Table Creation Failed: Key column 'PACId' doesn't exist in table:
Here is the first case it appears:
CREATE TABLE PlantAreaCodes(
PACId INT NOT NULL AUTO_INCREMENT,
AreaCode INT,
AreaName CHAR(32),
Comments TEXT,
PRIMARY KEY (PACId)
);
CREATE TABLE MajorEquipment(
MEId INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY (MEId),
FOREIGN KEY (PACId)
REFERENCES PlantAreaCodes(PACId)
);
Is it to do with the syntax of the foreign key, or is it because the PACId is still empty, and cannot be?