search

Home  >  Q&A  >  body text

MYSQL encountered syntax error 1064 (42000) when creating a new table

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粉982054449P粉982054449253 days ago487

reply all(1)I'll reply

  • P粉937769356

    P粉9377693562024-03-22 11:07:47

    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.

    reply
    0
  • Cancelreply