patternsqlMinor
What's wrong with this MySQL query?
Viewed 0 times
thiswhatwithquerymysqlwrong
Problem
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:
What's wrong?
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?
Solution
You are using the wrong quotes. Use ` instead of '
I also would recommend specifying the engine.
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.
Code Snippets
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;Context
StackExchange Database Administrators Q#20539, answer score: 4
Revisions (0)
No revisions yet.