在分析过程中发现了 4 个错误。
Ending quote ' was expected. (near "" at position 510)
A comma or a closing bracket was expected. (near "', `email` varchar(100) NOT NULL, `active` int(1) NOT NULL default ‘0'" at position 181)
Unexpected beginning of statement. (near "20" at position 268)
Unrecognized statement type. (near "NOT NULL" at position 272)
SQL查询:
CREATE TABLE IF NOT EXISTS `users`
(
`id` int(11) NOT NULL auto_increment,
`username` varchar(32) NOT NULL,
`password` varchar(32) NOT NULL,
`online` int(20) NOT NULL default ‘0',
`email` varchar(100) NOT NULL,
`active` int(1) NOT NULL default ‘0',
`rtime` int(20) NOT NULL default ‘0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
INSERT INTO `users` (`id`, `username`, `password`, `online`, `email`, `active`, `rtime`)
VALUES (1, ‘testing’, ‘testing’, 0, ‘fake@noemail.co.uk’, 0, 0);
最佳答案
例如,您使用不同类型的引号字符
`online` int(20) NOT NULL default ‘0',
here --------------------^
每次用完就换成普通的
CREATE TABLE IF NOT EXISTS `users`
(
`id` int(11) NOT NULL auto_increment,
`username` varchar(32) NOT NULL,
`password` varchar(32) NOT NULL,
`online` int(20) NOT NULL default '0',
`email` varchar(100) NOT NULL,
`active` int(1) NOT NULL default '0',
`rtime` int(20) NOT NULL default '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
但由于这些列的类型是 int
,所以您根本不需要在默认值周围加上引号。
关于mysql - 执行查询时出现 SQL 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38282002/