Reputation: 13
So when trying to create this table the console returns a syntax error that I just can't figure out.
CREATE TABLE Photobook( PhotoID INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
filepath VARCHAR(30) NULL, desc VARCHAR(500) NOT NULL);
this returns
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 'desc VARCHAR(500) NOT NULL)' at line 1
Upvotes: 1
Views: 45
Reputation: 175566
Quote reserved word DESC
with backticks:
Nonreserved keywords are permitted as identifiers without quoting. Reserved words are permitted as identifiers if you quote them.
CREATE TABLE Photobook( PhotoID INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
filepath VARCHAR(30) NULL, `desc` VARCHAR(500) NOT NULL);
or change column name to description
Upvotes: 1