Search code examples
mysqlmysql-error-1064

ERROR 1064 (42000): Error near 'Match( match_id INT(30) NOT NULL, club1_id CHAR(5), club1_score_id INT(30), club' at line 1


Keeps getting this error:

ERROR 1064 (42000): 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 'Match( match_id INT(30) NOT NULL, club1_id CHAR(5), club1_score_id INT(30), club' at line 1

Trying to create this table w/ a few foreign keys:

CREATE TABLE Match(
    match_id INT(30) NOT NULL,
    club1_id CHAR(5),
    club1_score_id INT(30),
    club2_id CHAR(5),
    club2_score_id INT(30),
    start_time TIME,
    end_time TIME,
    day INT(2),
    event_id INT(30),
    Primary Key(match_id),
    Foreign Key(club1_id) REFERENCES Club(club_id),
    Foreign Key(club2_id) REFERENCES Club(club_id),
    Foreign Key(club1_score_id) REFERENCES Score(score_id),
    Foreign Key(club2_score_id) REFERENCES Score(score_id),
    Foreign Key(event_id) REFERENCES Event(event_id));

Can't see anything that's wrong with it though. help?

This is the Database Design. Wouldn't mind some feedback on it too.

Database Design


Solution

  • Match is a reserved word. I would suggest changing it to Matches so you don't have to quote it when you use it. I usually name my tables in the plural, because they contain multiple entities, and plurals are less likely to conflict with reserved words.

    The list of reserved words is here.