2012-11-16 129 views
2

不知道我在做什麼錯在這裏:(MySQL的)SQL錯誤:ERROR 1054(42S22):在 '字段列表' 未知列 '<Column Name>'

mysql> use co_sysdev; 
Reading table information for completion of table and column names 
You can turn off this feature to get a quicker startup with -A 

Database changed 
mysql> select * from system_params; 
Empty set (0.01 sec) 

mysql> INSERT INTO system_params (NUM_ENGINE_D_PROCESSES,MAX_NUM_BATCHES_PER_CLIENT,MAX_NUM_BATCHES_PER_LOCATION) VALUES(5,8,2); 
ERROR 1054 (42S22): Unknown column 'NUM_ENGINE_D_PROCESSES' in 'field list' 
mysql> 

也:

desc system_params; 
+-----------+----------------------------------------------------------------------------------------------------+------+-----+---------+-------+ 
| Field  | Type                        | Null | Key | Default | Extra | 
+-----------+----------------------------------------------------------------------------------------------------+------+-----+---------+-------+ 
| attribute | enum('NUM_ENGINE_D_PROCESSES','MAX_NUM_BATCHES_PER_CLIENT','MAX_NUM_BATCHES_PER_LOCATION') | NO | PRI | NULL |  | 
| value  | varchar(256)                      | NO |  | NULL |  | 
+-----------+----------------------------------------------------------------------------------------------------+------+-----+---------+-------+ 
2 rows in set (0.00 sec) 

還有:

show create table system_params; 
+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 
| Table   | Create Table                                                             | 
+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 
| system_params | CREATE TABLE `system_params` (
    `attribute` enum('NUM_ENGINE_D_PROCESSES','MAX_NUM_BATCHES_PER_CLIENT','MAX_NUM_BATCHES_PER_LOCATION') NOT NULL, 
    `value` varchar(256) NOT NULL, 
    PRIMARY KEY (`attribute`) 
) ENGINE=InnoDB DEFAULT CHARSET=latin1 | 
+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 
1 row in set (0.01 sec) 
+1

什麼'show create table system_params'給你。 –

+2

夥計,'NUM_ENGINE_D_PROCESSES'是枚舉值,而不是列 – ajreal

+0

,因爲我是SQL新手,不確定-1是否公平。 – kamal

回答

4

您不能使用枚舉值作爲字段名稱。您的插入必須是像

INSERT INTO system_params (attribute, value) VALUES ('NUM_ENGINE_D_PROCESSES', 'foo'); 

除非可以在這裏插入你可能值是無限的(例如最終用戶自定義),你會下降一個非常非常痛苦的路徑。

1

也清楚這個錯誤說你正在使用錯誤的列名somwhere和NUM_ENGINE_D_PROCESSES是枚舉值,而你正在使用它作爲列... SQL插入查詢的語法應該像

INSERT INTO your_table_Name (ID, name, ...<column names goes here>...) 
VALUES ('1', 'John', ...<values goes here>...); 

在你的情況下

INSERT INTO system_params (attribute, value) VALUES ('NUM_ENGINE_BLA_BLA', 'foo'); 
相關問題