Isuru
Isuru

Reputation: 3958

What is wrong with the syntax near 'id'?

  CREATE TABLE post(
   'id' int UNSIGNED AUTO_INCREMENT,
   'title' VARCHAR(100),
   'content' VARCHAR(5000),
   'writer' VARCHAR(100),
   'updated_at' TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
   'created_at' DATETIME DEFAULT NULL,
   PRIMARY KEY(id)
  );

#1064 - 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 ''id' int UNSIGNED AUTO INCREMENT, 'title' VARCHAR(100), 'content' VARCHAR(5000' at line 2

Upvotes: 0

Views: 72

Answers (1)

Pekka
Pekka

Reputation: 449415

Field names need to be wrapped in backtics - quotes will cause an error.

So,

`id` int UNSIGNED AUTO_INCREMENT,
`title` VARCHAR(100),

etc.

Upvotes: 3

Related Questions