0

**Am working with MySQL 8.0 Command Line Client

I am trying to create a general table in mysql db but keep getting the following error:

"ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AUTO_INCREMENT, ManufacturerPTNO VARCHAR(40) NOT NULL, QuantityAvailable12am I' at line 2"

I have look through the manual but haven't found anything that helps with this issue; have also tried removing the index (id) column and assigning it as the KEY

CREATE TABLE quantity ( 
    id INT NOT NULL AUTO_INCREMENT, 
    ManufacturerPTNO VARCHAR(40) NOT NULL, 
    QuantityAvailable12am INT, 
    QuantityAvailable01am INT, 
    PRIMARY KEY (ManufacturerPTNO),
    );
Lelio Faieta
  • 6,457
  • 7
  • 40
  • 74
saddle_fish
  • 27
  • 1
  • 7
  • Possible duplicate of [How can I fix MySQL error #1064?](https://stackoverflow.com/questions/23515347/how-can-i-fix-mysql-error-1064) – Richard Jun 11 '19 at 15:25
  • 1
    `PRIMARY KEY (ManufacturerPTNO),` notice the extra comma i voteclose this as a simple typographical error. – Raymond Nijland Jun 11 '19 at 15:26

3 Answers3

0
CREATE TABLE quantity ( 
    id INT NOT NULL AUTO_INCREMENT, 
    ManufacturerPTNO VARCHAR(40) NOT NULL, 
    QuantityAvailable12am INT, 
    QuantityAvailable01am INT, 
    PRIMARY KEY (id)
    );

Primary key should be id

Updated answer as per you comment

CREATE TABLE quantity ( 
    id INT NOT NULL AUTO_INCREMENT, 
    ManufacturerPTNO VARCHAR(40) NOT NULL, 
    QuantityAvailable12am INT, 
    QuantityAvailable01am INT, 
    PRIMARY KEY (ManufacturerPTNO),
    UNIQUE KEY (id)
    );
Jimish Gamit
  • 1,014
  • 5
  • 15
0
CREATE TABLE quantity ( 
id INT NOT NULL AUTO_INCREMENT, 
ManufacturerPTNO VARCHAR(40) NOT NULL, 
QuantityAvailable12am INT, 
QuantityAvailable01am INT, 
PRIMARY KEY (ManufacturerPTNO),  <--- remove comma from here
);

and make PRIMARY KEY(id);

Kvyas
  • 21
  • 6
0

I had the same error message, after a long time I realized that I was trying to create a table by name "order" and that was the problem.As soon as I changed the name it worked!!!