(MySQL) SQL 错误:错误 1054 (42S22):“字段列表”中的未知列“<列名称>”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13422890/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
(MySQL) SQL Error : ERROR 1054 (42S22): Unknown column '<Column Name>' in 'field list'
提问by kamal
Not sure what i am doing wrong here:
不确定我在这里做错了什么:
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>
also:
还:
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)
also:
还:
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)
回答by Marc B
you can't use enum values as field names. Your insert has to be something like
您不能使用枚举值作为字段名称。你的插入必须是这样的
INSERT INTO system_params (attribute, value) VALUES ('NUM_ENGINE_D_PROCESSES', 'foo');
unless your possible values that can be inserted here are unbounded (e.g. end-user definable), you're going down a very very painful path.
除非您可以在此处插入的可能值是无限的(例如,最终用户可定义),否则您将走上一条非常痛苦的道路。
回答by Taimur Amjad
well clearly this error says you are using wrong column name somwhere and NUM_ENGINE_D_PROCESSES
is the enum value, and you are using it as column...
the syntax of SQL insert query should be like
很明显,此错误表明您在某处使用了错误的列名,并且NUM_ENGINE_D_PROCESSES
是枚举值,并且您将其用作列...... SQL 插入查询的语法应该是这样的
INSERT INTO your_table_Name (ID, name, ...<column names goes here>...)
VALUES ('1', 'John', ...<values goes here>...);
in your case
在你的情况下
INSERT INTO system_params (attribute, value) VALUES ('NUM_ENGINE_BLA_BLA', 'foo');