Question

I am creating few simple tables using Mysql command line. I got stock on the error number 150 while creating my Foreign Keys. Could you please help me with this one. I am kind of new to SQL. Thanks !

mysql> CREATE TABLE maintenancepersons (ServiceID INT NOT NULL AUTO_INCREMENT, 
MechanicID INT NOT NULL, 
ServiceName VARCHAR(100) NOT NULL, 
PRIMARY KEY ( ServiceID ), CarVIN INT NOT NULL, 
FOREIGN KEY ( CarVIN ) REFERENCES cars , 
CustomerID INT NOT NULL, FOREIGN KEY ( CustomerID ) REFERENCES  customers );
    ERROR 1005 (HY000): Can't create table 'dealership.maintenancepersons' (errno: 150)

No correct solution

OTHER TIPS

You are missing column name in your foreign key constraint

FOREIGN KEY ( CarVIN ) REFERENCES cars.CarVIN??

and

FOREIGN KEY ( CustomerID ) REFERENCES customers.??

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow