Pwned Pwned - 3 months ago 14
MySQL Question

#1064 - SQL Error when creating a table

So I wrote my query this way:

CREATE TABLE IF NOT EXISTS 'fontable' ( 'id' varchar(20) NOT NULL, 'hp' INTEGER NOT NULL, 'cur' INTEGER NOT NULL, 'next' INTEGER NOT NULL, 'num' INTEGER NOT NULL, 'bar' INTEGER NOT NULL, PRIMARY KEY('id'));


And it gives me this error:

#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 ''fontable' ( 'id' varchar(20) NOT NULL, 'hp' INTEGER NOT NULL, 'cur' I' at line 1


I didn't find anything wrong with the code, hope you can help me,
Thanks for reading

Answer

Use backticks (`) to encapsulate the table and field names, not apostrophe.

CREATE TABLE IF NOT EXISTS `fontable` ( `id`...
Comments