1

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??

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

You might try something like: "USE {DB_NAME}" and then your table creation statements or "CREATE TABLE {DB_NAME}.{TABLE_NAME}"
1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.