0
votes

I've checked other concerns like this. Checked if there were duplicates-none, if same data type -yep. relationships- yep. Not using "On Delete Set Null" checked.

I'm still lost how this error came to be

Executing SQL script in server

ERROR: Error 1215: Cannot add foreign key constraint


-- Table Apo.PurchasingOrder


CREATE TABLE IF NOT EXISTS Apo.PurchasingOrder (

PurchaseNo. INT NOT NULL AUTO_INCREMENT,

ModelNo. INT NULL,

UnitPrice INT NULL,

Product/Name VARCHAR(45) NULL,

Quantity INT NULL,

Source VARCHAR(45) NULL,

PRIMARY KEY (PurchaseNo.),

INDEX Source (Source ASC),

CONSTRAINT Supplier_Source

FOREIGN KEY (`PurchaseNo.`)

REFERENCES `Apo`.`Supplier` (`SupplierID`)

ON DELETE NO ACTION

ON UPDATE NO ACTION)

ENGINE = InnoDB

SQL script execution finished: statements: 9 succeeded, 1 failed

Fetching back view definitions in final form.

Nothing to fetch

1
Is this Microsoft sql? if so you should add that tag - benathon

1 Answers

0
votes

Could you check whether all your PurchaseNo values in Apo.PurchasingOrder are valid values of SupplierID in Apo.Supplier?