Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

I get ER_PARSE_ERROR when trying to CREATE a TABLE with PRIMARY KEY and FOREIGN KEY

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…

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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
);
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading