Brendon Rother
Brendon Rother

Reputation: 119

SQL create table code

I'm trying to create two MySql tables

CREATE TABLE customer (
     custID int(11) NOT NULL AUTO_INCREMENT,
     custName varchar(50) NOT NULL,
     custPwd varchar(64) NOT NULL,
     custEmail varchar(100) NOT NULL,
     custPhone varchar(10) NOT NULL,
     PRIMARY KEY (custID))

CREATE TABLE request (  
    requestID int(11) NOT NULL AUTO_INCREMENT,
    custID int(11) NOT NULL,    
    requestDate date NOT NULL,
    itemDesc varchar(200) NOT NULL,
    itemWeight int(11) NOT NULL,
    puAdd varchar(100) NOT NULL,
    puSuburb varchar(50) NOT NULL,
    puDate date NOT NULL,
    puTime time NOT NULL,
    dName varchar(50) NOT NULL,
    dAdd varchar(100) NOT NULL,
    dSuburb varchar(50) NOT NULL,
    dState varchar(50) NOT NULL,
    PRIMARY KEY (requestID),
    FOREIGN KEY (custID) REFERENCES customer(CustID))

I keep getting errors saying that there is an error near the first statement. I can't seem to figure out what is actually wrong. Am I missing something really obvious or??

Upvotes: 1

Views: 846

Answers (2)

Brendon Rother
Brendon Rother

Reputation: 119

The issue was that there was white space after the open bracket eg. CREATE TABLE customer ("white space"...

Once I deleted the white space everything worked

Upvotes: 1

Travis Prescott
Travis Prescott

Reputation: 417

Assuming you are writing these queries in MySQL Workbench, you need to end each statement with a semicolon. I did this and they ran just fine.

Upvotes: 2

Related Questions