MySQL error #1054 - Unknown column in 'Field List' -


whenever try input data tblorder error message #1054 - unknown column 'fk_customer_id' in 'field list'. have tried breaking code down , in doing found error repeated fk_customer_id , orderquantity whereas fk_dvd_id take single data entries. have tried dropping table , recreating it, have dropped database , recreated nothing works. far can tell code correct along spelling i'm stuck.

my tblorder is-

create table tblorder (     order_id int auto_increment not null,    fk_customer_id int not null,     fk_dvd_id int not null,      orderdate datetime not null default now(),  orderqantity int not null,   primary key (order_id),      foreign key (fk_customer_id) references tblcustomer (customer_id),   foreign key (fk_dvd_id) references tbldvd (pk_id) ); 

the data trying put in is-

insert tblorder  (fk_customer_id, fk_dvd_id, orderquantity) values   (1, 3, 2),  (1, 5, 1),  (1, 10, 4),   (1, 15, 3),  (2, 5, 4),  (2, 17, 3),  (3, 15, 1),  (3, 16, 1),  (3, 17, 1); 

fk_customer_id addressing -

create table tblcustomer (  customer_id int auto_increment not null,  firstname varchar(50) not null,  lastname varchar(50) not null,  age int not null,  primary key (customer_id) ); 

fk_dvd_id addressing -

create table tbldvd (  pk_id int auto_increment not null,  title varchar(100) not null,  director varchar(100) not null,  genre varchar(40) not null,  dvd_year year not null,  price float(2) not null,  quantity int not null,  primary key (pk_id) ); 

any in fixing appreciated me a2 computing lesson!

you have error in orderquantity column. named "orderquantity" in insert statement , "orderqantity" in table definition.

also, don't think can use now() default value in orderdate. try use following:

 orderdate timestamp not null default current_timestamp 

example fiddle


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -