MySQL 如何修复错误 #1054 字段中的未知列
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28059779/
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
how to fix error #1054 unknown column in field
提问by Lenroy D Chandler
This is my table.
这是我的桌子。
create table Property(
p_id int(4) null primary key,
p_address varchar(120) not null,
c_id int(4) not null,
foreign key (c_id) references customer (c_id)
);
insert into Property values
('2001','Elm_House_11_Short_Lane_Hertfordshire_H5_667','3001');
insert into Property values
('2002','Jainlight_House_Apple_Lane_Kent_K7_988','3002');
insert into Property values
('2003','Excelsior_House_23_Oracle_Centre_Reading','3003');
insert into Property values ('2004','27_Wroxton_Road_London_SE15','3004');
I'm keep getting an unknown column error when entering this data.
输入此数据时,我不断收到未知列错误。
回答by Jens
remove the quotes and backticks when you insert int
values:
插入int
值时删除引号和反引号:
insert into Property values
(2001,'Elm_House_11_Short_Lane_Hertfordshire_H5_667',3001);
insert into Property values
(2002,'Jainlight_House_Apple_Lane_Kent_K7_988',3002);
insert into Property values
(2003,'Excelsior_House_23_Oracle_Centre_Reading',3003);
insert into Property values (2004,'27_Wroxton_Road_London_SE15',3004);
Quotes are only needed, when you working with char
fields and backticks are escape characters for table or column names.
只有在处理char
字段时才需要引号,反引号是表名或列名的转义字符。
回答by user2587656
I got this error exporting from MariaDb and then importing into MySql. It concerned a field that I had recently added and for which I hadn't added values yet - so in all records this field was empty. When I added a few values for this field the error disappeared.
我从 MariaDb 导出然后导入到 MySql 时遇到了这个错误。它涉及我最近添加的一个字段,但我尚未为其添加值 - 因此在所有记录中该字段都是空的。当我为此字段添加一些值时,错误消失了。