0

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)
Tomala
  • 527
  • 2
  • 8
  • 19
  • possible duplicate of [Mysql. Can't create table errno 150](http://stackoverflow.com/questions/1749332/mysql-cant-create-table-errno-150) – Phil Mar 04 '14 at 04:10
  • This link may be helpful for your question http://stackoverflow.com/questions/825362/mysql-error-150-foreign-keys – Sadikhasan Mar 04 '14 at 04:12

1 Answers1

1

You are missing column name in your foreign key constraint

FOREIGN KEY ( CarVIN ) REFERENCES cars.CarVIN??

and

FOREIGN KEY ( CustomerID ) REFERENCES customers.??

Riz
  • 1,119
  • 15
  • 23