Last answered:

01 Nov 2021

Posted on:

24 Oct 2021

0

I keep getting an error setting primary key

I tried setting my primary key, purchase number using the alternative method but it keeps popping up an error, is there anything wrong with my code, please

CREATE TABLE sales
(
purchase_number INT NOT NULL auto_increment,
    date_of_purchase DATE NOT NULL,
    customer_id INT,
    item_code VARCHAR(10) NOT NULL
PRIMARY KEY (purchase_number)
);

1 answers ( 0 marked as helpful)
Instructor
Posted on:

01 Nov 2021

1

Hi Ajayi!

Thanks for reaching out.

You've just missed the comma before designating the primary key. Please add it and retry running the query.

    item_code VARCHAR(10) NOT NULL,
PRIMARY KEY (purchase_number)

Hope this helps.
Best,
Martin

Submit an answer