4

I am getting a syntax error for my MySQL (5.5.24) query.

The error is:

#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 ''topics'( 'topicid' int unsigned not null auto_increment primary key, 'creator' at line 1

The query is:

create table 'topics'(
 'topicid' int unsigned not null auto_increment primary key,
 'creator' varchar(255) not null,
 'createtime' datetime not null,
 'content' text not null
);

What's wrong?

Mat
10.3k4 gold badges44 silver badges40 bronze badges
asked Jul 8, 2012 at 14:43

3 Answers 3

4

You are using the wrong quotes. Use ` instead of '

CREATE TABLE `topics` (
 `topicid` int(11) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
 `creator` varchar(255) NOT NULL,
 `createtime` datetime NOT NULL,
 `content` text NOT NULL
) ENGINE=InnoDB;

I also would recommend specifying the engine.

answered Jul 8, 2012 at 15:09
0
2

The error is the single quotes around the table and column names. If you want to escape these names use back ticks (`) not quotes.

answered Jul 8, 2012 at 15:08
0
1

Why are you using quotes? Try

CREATE TABLE topics (
 topicid int(11) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
 creator varchar(255) NOT NULL,
 createtime datetime NOT NULL,
 content text NOT NULL
);
Glorfindel
2,2095 gold badges19 silver badges26 bronze badges
answered May 31, 2019 at 10:06

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.