0

I am new to MYSQL and I am working on a many to many table 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

The 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 am not sure why I am getting this error

Kadwen
  • 51
  • 8
  • rank is a reserved word see https://dev.mysql.com/doc/refman/8.0/en/keywords.htmlfor how to deal with this - or change to another name. – P.Salmon Nov 04 '22 at 13:12

1 Answers1

0

As per P.Salmon it was because the name of rank. After looking at dev.mysql.com/doc/refman/8.0/en/keywords.html just changed rank to rank and it worked.

Kadwen
  • 51
  • 8