Error in SQL Syntax using Foreign Keys

时间:2016-02-12 19:51:07

标签: mysql sql syntax foreign-keys

Something is wrong with the code I have down below. Checking for SQL Syntax validators online reveal something is wrong with the last line. I cant figure out what though.

CREATE TABLE module3.eventrequest (
`EVENTNO` VARCHAR(8) NOT NULL,
`DATEHELD` DATE NOT NULL,
`DATEREQ` DATE NOT NULL,
`CUSTNO` VARCHAR(8) NOT NULL, 
`FACNO` VARCHAR(8) NOT NULL, 
`DATEAUTH` DATE NOT NULL, 
`STATUS` VARCHAR(48) NOT NULL,
`ESTCOST` VARCHAR(48) NOT NULL,
`ESTAUDIENCE` VARCHAR(48) NOT NULL,
`BUDNO` VARCHAR(48) NOT NULL,
CONSTRAINT PK_EventNumber PRIMARY KEY (EventNo)
FOREIGN KEY (CUSTNO) REFERENCES customer(CUSTNO)
)

Any Ideas? Using MySQL workbench.

// I've updated the code to use references. I have a table customer with CUSTNO as primary key.

1 个答案:

答案 0 :(得分:0)

I've wasted an hour, and learned it the hard way. "," can absolutely ruin your life, and thats what all I was missing. A simple comma. Fixed code:

DelegatingScript