我正在尝试在我的游戏中添加一个插件,我需要将此查询添加到mysql中,查询如下:
CREATE TABLE `streets` (
`id` int(11) NOT NULL auto_increment,
`min_level` int(11) NOT NULL,
`text` longtext NOT NULL,
`query` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MYISAM ;
INSERT INTO `settings` (`conf_id`, `conf_name`, `conf_value`) VALUES ('NULL', 'steps_daily', '100')
ALTER TABLE `users` ADD `steps` INT( 11 ) NOT NULL ;
当我尝试将查询输入sql时,我收到此错误:
Error
SQL query:
INSERT INTO `settings` ( `conf_id` , `conf_name` , `conf_value` )
VALUES (
'NULL', 'steps_daily', '100'
)
ALTER TABLE `users` ADD `steps` INT( 11 ) NOT NULL ;
MySQL said: Documentation
#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 'ALTER TABLE `users` ADD `steps` INT( 11 ) NOT NULL' at line 3
答案 0 :(得分:3)
您在;
查询后忘记了INSERT INTO
。
CREATE TABLE `streets` (
`id` int(11) NOT NULL auto_increment,
`min_level` int(11) NOT NULL,
`text` longtext NOT NULL,
`query` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MYISAM ;
INSERT INTO `settings` (`conf_id`, `conf_name`, `conf_value`) VALUES
(NULL, 'steps_daily', '100');
ALTER TABLE `users` ADD `steps` INT( 11 ) NOT NULL ;
P.S。:NULL
不应该在引号中。您需要值 NULL
,而不是文字字符串,'NULL'
。
答案 1 :(得分:1)
不要为NULL使用引号然后尝试。
INSERT INTO `settings` ( `conf_id` , `conf_name` , `conf_value` )
VALUES (NULL, 'steps_daily', '100');