执行语句时出现MySQL错误

时间:2015-10-14 14:11:35

标签: php mysql

我是一个相对较新的程序员,我正在为类创建一个基本的mysql数据库。

我需要一些我似乎无法解决的错误消息的帮助。

这是我得到的错误:

ERROR 1064 (42000) at line 1: 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 ')
    FOREIGN KEY(team_id)
        REFERENCES team(id)     
)' at line 8

我的代码:

  CREATE TABLE cyclist (
        cyclist_id INT AUTO_INCREMENT,
        team_id INT,
        firstname VARCHAR(50),
        lastname VARCHAR(50),
        Gender VARCHAR(50),
        Age INT,
        PRIMARY KEY(cyclist_id,)
        FOREIGN KEY(team_id)
                REFERENCES team(id)
);

CREATE TABLE team (
        id INT AUTO_INCREMENT,
        team_name VARCHAR(50),
        main_colour VARCHAR(50),
        year_established VARCHAR(50),
        sponsor VARCHAR(50),
        budget INT,
        PRIMARY KEY(team_id),
        FOREIGN KEY(bike_brand)
        );

CREATE TABLE race (
        race_name VARCHAR(50),
        team_capacity INT,
        prize_money INT,
        main_sponsor VARCHAR(50),
                PRIMARY KEY(race_name)
);

CREATE TABLE bikes (
        bike_brand VARCHAR(50),
        cost INT,
        colour VARCHAR(50),]
);

有人可以对此有所了解吗?

谢谢!

1 个答案:

答案 0 :(得分:2)

PRIMARY KEY(cyclist_id,)

删除逗号并将其放在=>之后PRIMARY KEY(cyclist_id),