0
CREATE TABLE inventory
(
   id INT IDENTITY(1,1) PRIMARY KEY,
   product VARCHAR(50) UNIQUE,
   quantity INT,
   price DECIMAL(18,2)
);

error is

Error Code : 1064
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 'IDENTITY(1,1) PRIMARY KEY,
   product VARCHAR(50) UNIQUE,
   quantity INT,
   pr' at line 3
Nishant
  • 54,584
  • 13
  • 112
  • 127

2 Answers2

0
CREATE TABLE inventory
(
   id INT PRIMARY KEY,
   product VARCHAR(50) UNIQUE,
   quantity INT,
   price DECIMAL(18,2)
);

This worked. I removed IDENTITY. I do not see IDENTITY in the create table doc of MySQL.


EDIT1 (got that OP's wrong syntax exported from T-SQL)

Ahh I got it... you are taking the SQL from T-SQL? Perhaprs you need auto increment use this

CREATE TABLE inventory
(
   id INT AUTO_INCREMENT PRIMARY KEY,
   product VARCHAR(50) UNIQUE,
   quantity INT,
   price DECIMAL(18,2)
);
Nishant
  • 54,584
  • 13
  • 112
  • 127
0

I think you want to use AUTO_INCREMENT. Try this:

CREATE TABLE inventory
(
   id INT AUTO_INCREMENT PRIMARY KEY,
   product VARCHAR(50) UNIQUE,
   quantity INT,
   price DECIMAL(18,2)
);
Himanshu
  • 31,810
  • 31
  • 111
  • 133