MYSQL encountered syntax error 1064 (42000) when creating a new table
P粉982054449
P粉982054449 2024-03-21 22:32:39
0
1
486

I am new to MYSQL and am working with many to many tables and when I try to create the table I get the following 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 'rank INTEGER,
  year INTEGER,
  description TEXT,
  PRIMARY KEY(position_id),
  ' at line 4

Create call is

CREATE TABLE Position (
  position_id INTEGER NOT NULL AUTO_INCREMENT,
  profile_id INTEGER,
  rank INTEGER,
  year INTEGER,
  description TEXT,
  PRIMARY KEY(position_id),
  CONSTRAINT position_ibfk_1
    FOREIGN KEY (profile_id)
    REFERENCES Profile (profile_id)
    ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Everything looks clean so I'm not sure why I'm getting this error

P粉982054449
P粉982054449

reply all(1)
P粉937769356

According to P.Salmon, this is because of the name of the level. After looking at dev.mysql.com/doc/refman/8.0/en/keywords.html I changed the rank to rank and it worked.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template