Search code examples
mysqlmysql-error-1064create-table

MySql create table error expexting REFERENCES


Here is my code, i get an error at the very last line (syntax error, unexpected ')', expecting REFERENCES)

CREATE TABLE `MyDB`.`Product`(
`Product_ID` int AUTO_INCREMENT,
`Category_ID` int(2),
`Supplier_VAT` int(10),
`Product_Name` varchar(20),
`Description` varchar(300),
KEY (`Product_ID`),
PRIMARY KEY (`Product_ID`),
FOREIGN KEY (`Category_ID`,`Supplier_VAT`)
);

Any help is appreciated.

Thanks in advance.

EDIT: I figured, that the error is caused by the foreign key line, still don't know why though. :/


Solution

  • ...    
    FOREIGN KEY (`Category_ID`,`Supplier_VAT`) REFERENCES tbl_name (index_col_name_1, index_col_name_2)
    

    should fix your problem!