There's an error in my syntax, I don't know where

mysql> CREATE TABLE customer_status(
    status_id INT NOT NULL AUTO_INCREMENT,
    name VARCHAR (50) NOT NULL,
    rank INT NOT NULL,
    PRIMARY KEY(status_id))
    ENGINE=innodb
    CHARSET=latin1
    COLLATE=latin1_general_ci;

SEEMS THAT I CAN’T USE THE WORD RANK

>Solution :

RANK is a reserved word in MySQL. You can escape it with the backtick (`) character.

CREATE TABLE customer_status(
status_id INT NOT NULL AUTO_INCREMENT,
name VARCHAR (50) NOT NULL,
`rank` INT NOT NULL,
PRIMARY KEY(status_id))
ENGINE=innodb
CHARSET=latin1
COLLATE=latin1_general_ci;

Leave a Reply