Danestyles Danestyles - 2 months ago 13
MySQL Question

can not get date to work

CREATE TABLE Customer (customerid varchar(10) NOT NULL, FirstName varchar(20) NOT NULL, LastName varchar(20) NOT NULL, StreetAddress varchar (30) NOT NULL, City varchar (20)NOT NULL, State varchar (20) NOT NULL, Zip varchar(10) NOT NULL, Hphone varchar (30) NOT NULL, Mphone varchar (30) NOT NULL, Ophone varchar (30) NOT NULL, PRIMARY KEY (customerid));

CREATE TABLE OrderTable
(
donutorderid varchar(10) NOT NULL,
customerid varchar (10) NOT NULL,
oderdate datetime (6) NOT NULL,
PRIMARY KEY (donutorderid)
);
CREATE TABLE Donut
(
donutid varchar(10),
donutname varchar(20),
description varchar(30),
unitprice numeric,
PRIMARY KEY (donutid)
);
CREATE TABLE OrderLine
(donutorderid varchar (30),
donutid varchar (30),
qty int (10),
PRIMARY KEY (donutorderid,donutid)
);
ALTER TABLE OrderTable ADD INDEX checks (customerid), ADD CONSTRAINT checks FOREIGN KEY (customerid) REFERENCES Customer (customerid);
ALTER TABLE OrderLine ADD INDEX has (donutorderid), ADD CONSTRAINT has FOREIGN KEY (donutorderid) REFERENCES OrderTable (donutorderid);
ALTER TABLE OrderLine ADD INDEX available_in (donutid), ADD CONSTRAINT available_in FOREIGN KEY (donutid) REFERENCES Donut (donutid);

create view CustInfo
AS Select customerid, concat(FirstName,LastName) as FullName from customer;

insert into customer(customerid, FirstName, LastName, StreetAddress, City, State, Zip, Hphone, Mphone, Ophone) values
('123','John','Doe', 'one hoover lane', 'las vegas', 'nevada', 89104, 7025551212, 7024441111, 7023332222);
insert into customer(customerid, FirstName, LastName, StreetAddress, City, State, Zip, Hphone, Mphone, Ophone) values
('456','Jim','Jones', '2121 crisco street', 'las vegas', 'nevada', 89104, 7025551223, 7024441112, 7023332224);
insert into donut(donutid,donutname,description,unitprice) values
('123','Jelly Donut','Creamy Donut',1.00);
insert into donut(donutid,donutname,description,unitprice) values
('124','Sprinkle Donut','Nutty Donut',5.00);


This is the statement which gives error:

insert into ordertable(donutorderid,customerid, orderdate) values('123','123', '2016-9-25 12:01:01');


The error is:


Unknown column 'orderdate' in 'field list'

Answer

In your CREATE TABLE statement, you have misspelled orderdate as oderdate. Fix that and your problem is solved.

CREATE TABLE OrderTable
(
  donutorderid varchar(10) NOT NULL, 
  customerid varchar (10) NOT NULL,
  orderdate datetime (6) NOT NULL,
  PRIMARY KEY (donutorderid)
);
Comments