Freedom Gu
Freedom Gu

Reputation: 61

MySQL ERROR 1064(42000) when using , instead of ,

When am trying to create a table, I meet this error and can't find a solution.

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 'NULL, course_code CHAR(5) NOT NULL, name VARCHAR(150) NOT NULL, PRIMARY KEY(co' at line 1

and the code for creating the table is:

create table courses
( 
    school_code ENUM('L', 'B', 'A', 'F', 'E', 'T', 'I', 'W', 'S', 'U', 'M') NOT NULL, 
    dept_id TINYINT UNSIGNED NOT NULL, 
    course_code CHAR(5) NOT NULL, 
    name VARCHAR(150) NOT NULL, 
    PRIMARY KEY(course_code), 
    FOREIGN key (school_code, dept_id) 
    REFERENCES departments (school_code, dept_id) 
)
engine = INNODB DEFAULT character SET = utf8 COLLATE = utf8_general_ci;

Upvotes: 2

Views: 382

Answers (1)

Tom Chadaravicius
Tom Chadaravicius

Reputation: 393

dept_id TINYINT UNSIGNED NOT NULL,

should be followed by comma. It's not a comma in your code, it just looks like comma.
Below please find same code with a comma:

dept_id TINYINT UNSIGNED NOT NULL,

Upvotes: 6

Related Questions