简体   繁体   中英

MySQL 1064 Error Creating a Linking Table (Many-to-Many)

I'm trying to understand why a parsing error occurred (1064) with the following code.

<#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 3>

CREATE TABLE Party_Library
(
    Party INT(11)
    Library varchar(40)
    PRIMARY KEY (Library,Party)
    FOREIGN KEY (Party) REFERENCES Party(PartyKey) ON DELETE CASCADE
    FOREIGN KEY (Library) REFERENCES MusicLibraries(MusicSource) ON DELETE CASCADE
)

You are missing commas after each declaration:

CREATE TABLE Party_Library
(
    Party INT(11),
    Library varchar(40),
    PRIMARY KEY (Library,Party),
    FOREIGN KEY (Party) REFERENCES Party(PartyKey) ON DELETE CASCADE,
    FOREIGN KEY (Library) REFERENCES MusicLibraries(MusicSource) ON DELETE CASCADE
);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM