Da Phuc Da Phuc - 3 months ago 7
MySQL Question

Getting error in SQL Statements

CREATE TABLE Order (
`Type` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
Order_Type INT NOT NULL,
Order_Number VARCHAR(45) NOT NULL,
Order_Date VARCHAR(45) NOT NULL
);


Why I'm getting error, I'm using a correct syntax.

I'm getting three errors which are:


  1. The name of the entity was expected (near Order)

  2. Unexpected beginning of statement (near 'Type')

  3. Unrecognized statement type. (near INT)


Answer

Yes its the keyword, it would better to not to use this if still you want then try in this way and in every operation you have to enclose table name in typos:

CREATE TABLE `Order` (
`Type` INT NULL AUTO_INCREMENT PRIMARY KEY,
 Order_Type INT NOT NULL,
 Order_Number VARCHAR(45) NOT NULL,
 Order_Date VARCHAR(45) NOT NULL
 );