Home > Back-end >  I get ER_PARSE_ERROR when trying to CREATE a TABLE with PRIMARY KEY and FOREIGN KEY
I get ER_PARSE_ERROR when trying to CREATE a TABLE with PRIMARY KEY and FOREIGN KEY

Time:11-08

I'm learning SQL and from time to time I get this error: ER_PARSE_ERROR. For example:

`CREATE TABLE branch_supplier(
    branch_id INT,
    supplier_name VARCHAR(40),
    suply_type INT,
    PRIMARY KEY(branch_id, supplier_name),
    FOREIGN KEY(branch_id) REFERENCES branch(branch_id) ON DELETE SET CASCADE
);`

What I get wrong is the ');'

I tried to rewrite the code, restart PopSQL program but non of them worked...

CodePudding user response:

remove set keyword :

CREATE TABLE branch_supplier(
    branch_id INT,
    supplier_name VARCHAR(40),
    suply_type INT,
    PRIMARY KEY(branch_id, supplier_name),
    FOREIGN KEY(branch_id) REFERENCES branch(branch_id) ON DELETE CASCADE
);
  • Related