Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to fix error #1054 unknown column in field

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.

like image 659
Lenroy D Chandler Avatar asked Jan 10 '23 01:01

Lenroy D Chandler


1 Answers

remove the quotes and backticks when you insert int values:

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.

like image 162
Jens Avatar answered Jan 15 '23 06:01

Jens