I am creating 3 subclass table, other 2 is done and work normally but I get this error(1064) when I enter the following code for the last table:
mysql> CREATE TABLE foreign (
-> account_no VARCHAR(16) NOT NULL,
-> foreign_id VARCHAR(16) NOT NULL,
-> TYPE CHAR(4) DEFAULT 'FORE' NOT NULL
-> CHECK ( TYPE = 'FORE'),
-> currency_TYPE CHAR(3) NOT NULL
-> CHECK ( currency_TYPE IN ('EUR','USD','HKD')),
-> balance DECIMAL(16,2),
-> PRIMARY KEY(account_no, foreign_id),
-> FOREIGN KEY(account_no, TYPE)
-> ON UPDATE CASCADE
-> ON DELETE CASCADE);
the error message informs me that between foreign( account_no VARCHAR(16) NOT NULL, foreign_id VARCHAR(16) NOT NULL, TYPE gets wrong syntax, but I can’t find it, is there anything wrong?
For FOREIGN KEY(account_no, TYPE) you need to give Reference columns
Example