-1

我正在尝试在我的游戏中添加一个插件,我需要将此查询添加到 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 
4

2 回答 2

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 ;

PS:NULL不应该用引号引起来。您想要的是 NULL,而不是文字字符串'NULL'

于 2013-09-17T15:03:49.567 回答
1

不要为 NULL 使用引号,然后尝试。

INSERT INTO  `settings` (  `conf_id` ,  `conf_name` ,  `conf_value` ) 
VALUES (NULL,  'steps_daily',  '100');
于 2013-09-17T15:03:48.850 回答