0

For some reason the first two tables will query in SQL FIDDLE if I put them into SQL Fiddle by themselves. When I put all tables in no table will query and I get the Message: Table db_9_9eecb7d.customer doesn't exist. Any hints or help would be appreciated.

Here is the code I wrote:

CREATE TABLE Customer
(   CustomerID INT(255) NOT NULL AUTO_INCREMENT,
    FirstName VARCHAR(255) NOT NULL,
    LastName VARCHAR(255) NOT NULL,
    StreetAddress VARCHAR(255) NOT NULL,
    Apartment VARCHAR(255) NOT NULL,
    City VARCHAR(255) NOT NULL,
    State VARCHAR(2) NOT NULL,
    ZipCode CHAR(9) NOT NULL,
    HomePhone CHAR(10) NOT NULL,
    MobilePhone CHAR(10) NOT NULL,
    OtherPhone CHAR(10) NOT NULL,
    PRIMARY KEY(CustomerID)
);

INSERT INTO Customer
    (FirstName, LastName, StreetAddress, Apartment, City, State,
        ZipCode, HomePhone, MobilePhone, OtherPhone)
VALUES('Joe', 'Shmoe', '190 Pine St', ' A 708 ', 'Polk',
    'WA', 98408, 4173231111, 1234567788, 5555551212);

SELECT CustomerID, (CONCAT(firstname, ' ', Lastname)) as FullName, StreetAddress, Apartment, City, State, ZipCode, Homephone, mobilephone, otherphone FROM customer;

CREATE TABLE Donut
(   
    DonutID INT(255) NOT NULL AUTO_INCREMENT,
    Name VARCHAR(255) NOT NULL,
    Description VARCHAR(255) NOT NULL,
    UnitPrice DECIMAL(3, 2) NOT NULL,
    PRIMARY KEY(DonutID
);

INSERT INTO Donut(Name, Description, UnitPrice)
VALUES('Plain', 'Plain Donut', '1.50'), ('Glazed', 'Glazed Donut', '1.75'), ('Cinnamon', 'Cinnamon Donut', '1.75'), ('Chocolate', 'Chocolate Donut', '1.75'), ('Sprinkle', 'Sprinkle Donut', '1.75'), ('Gluten-Free', 'Gluten-Free Donut', '2.00');

CREATE INDEX DonutName ON Donut(Name);

CREATE TABLE DonutOrder
    (DonutOrderID INT(255) NOT NULL,
        DonutID INT(255) NOT NULL,
        Quantity INT(255),
        PRIMARY KEY(DonutOrderID, donutID),
        INDEX Donut(donutID));

INSERT INTO DonutOrder(DonutID, Quantity)
VALUES((SELECT DonutID FROM Donut WHERE DonutID = 1), 1), 
      ((SELECT DonutID FROM Donut WHERE DonutID = 2), 5), 
      ((SELECT DonutID FROM Donut WHERE DonutID = 3), 12), 
      ((SELECT DonutID FROM Donut WHERE DonutID = 4), 3), 
      ((SELECT DonutID FROM Donut WHERE DonutID = 5), 4), 
      ((SELECT DonutID FROM Donut WHERE DonutID = 6), 5);

CREATE TABLE SalesInvoice
(
    CustomerID INT(255) NOT NULL,
    DonutOrderID INT(255) NOT NULL AUTO_INCREMENT,
    `Date`
    date NOT NULL,
    Spec_Hnd_Inst VARCHAR(255),
    PRIMARY KEY(DonutOrderID),
    INDEX Customer(CustomerID),
    FOREIGN KEY(CustomerID) REFERENCES Customer(CustomerID),
    INDEX DonutOrder(donutOrderID));

INSERT INTO SalesInvoice(CustomerID, DonutOrderID, `Date`, Spec_Hnd_Inst) VALUES(1, 1, '20160319', 'Extra Sugar');
Anonymous Duck
  • 2,942
  • 1
  • 12
  • 35
  • 1
    Make sure the case of your table names and your statements matches *exactly*. On some operating systems [this is a big deal](http://stackoverflow.com/questions/6134006/are-table-names-in-mysql-case-sensitive). – tadman Mar 29 '16 at 01:27

1 Answers1

0

This seems to work.

Add the following to the left to build schema

CREATE TABLE Customer
(CustomerID INT(255) NOT NULL AUTO_INCREMENT,
FirstName VARCHAR(255) NOT NULL,
LastName VARCHAR(255) NOT NULL,
StreetAddress VARCHAR(255) NOT NULL,
Apartment VARCHAR(255) NOT NULL,
City VARCHAR(255) NOT NULL,
State VARCHAR(2) NOT NULL,
ZipCode CHAR(9) NOT NULL,
HomePhone CHAR(10) NOT NULL,
MobilePhone CHAR(10) NOT NULL,
OtherPhone CHAR(10) NOT NULL,
PRIMARY KEY (CustomerID));
INSERT INTO Customer 
(FirstName, LastName, StreetAddress, Apartment, City, State,
ZipCode, HomePhone, MobilePhone, OtherPhone)
VALUES ('Joe', 'Shmoe', '190 Pine St', ' A 708 ', 'Polk', 
'WA', 98408, 4173231111, 1234567788, 5555551212);
SELECT CustomerID, (CONCAT (firstname, ' ', Lastname)) as FullName, StreetAddress, Apartment, City, State, ZipCode, Homephone, mobilephone, otherphone FROM customer;

CREATE TABLE Donut
(DonutID INT(255) NOT NULL AUTO_INCREMENT,
Name VARCHAR(255) NOT NULL,
Description VARCHAR(255) NOT NULL,
UnitPrice DECIMAL(3,2) NOT NULL,
PRIMARY KEY (DonutID));
INSERT INTO Donut (Name, Description, UnitPrice)
VALUES ('Plain', 'Plain Donut', '1.50'),
('Glazed', 'Glazed Donut', '1.75'),
('Cinnamon', 'Cinnamon Donut', '1.75'),
('Chocolate', 'Chocolate Donut', '1.75'),
('Sprinkle', 'Sprinkle Donut', '1.75'),
('Gluten-Free', 'Gluten-Free Donut', '2.00');
CREATE INDEX DonutName ON Donut (Name);

CREATE TABLE DonutOrder
(DonutOrderID INT (255) NOT NULL AUTO_INCREMENT,
DonutID INT(255) NOT NULL,
Quantity INT(255),
PRIMARY KEY (DonutOrderID, donutID),
INDEX Donut(donutID));
INSERT INTO DonutOrder (DonutID, Quantity)
VALUES ((SELECT DonutID FROM Donut WHERE DonutID = 1), 1),
   ((SELECT DonutID FROM Donut WHERE DonutID = 2), 5),
   ((SELECT DonutID FROM Donut WHERE DonutID = 3), 12),
   ((SELECT DonutID FROM Donut WHERE DonutID = 4), 3),
   ((SELECT DonutID FROM Donut WHERE DonutID = 5), 4),
   ((SELECT DonutID FROM Donut WHERE DonutID =6), 5);

CREATE TABLE SalesInvoice
(CustomerID INT(255) NOT NULL,
DonutOrderID INT(255) NOT NULL AUTO_INCREMENT,
Date date NOT NULL,
Spec_Hnd_Inst VARCHAR(255),
PRIMARY KEY (DonutOrderID),
INDEX Customer (CustomerID),
FOREIGN KEY (CustomerID) REFERENCES Customer(CustomerID),
INDEX DonutOrder (donutOrderID));

INSERT INTO SalesInvoice (CustomerID, DonutOrderID, Date,Spec_Hnd_Inst ) VALUES (1, 1, '20160319', 'Extra Sugar');

And add the following to the right to check inserted values

select * from SalesInvoice;

Table 'db_9_9eecb7d.customer'

I'm not getting this error, but it seems quite simple--the table customer isn't found. Databases can be case-sensitive depending on its configuration, so try using Customer instead

itzmebibin
  • 9,199
  • 8
  • 48
  • 62
jrhee17
  • 1,152
  • 9
  • 19
  • Did anyone do anything with it because it is working now with simple queries? I didn't see any changes. Is this a SQLFiddle issue? If there was a change Thanks it works now! – user3078797 Mar 29 '16 at 02:52