0
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)
Bill Karwin
  • 538,548
  • 86
  • 673
  • 828
Da Phuc
  • 1
  • 1
  • 5
  • 1
    `Order` is a SQL keyword and MySQL reserved word. I would suggest using `orders` (I usually name tables in the plural). I vote to close such questions as a simple typographical error. – Gordon Linoff Sep 04 '16 at 13:21
  • Sorry I didn't know Order was a SQL keyword. I'm currently learning SQL at this moment anyways thanks! – Da Phuc Sep 04 '16 at 13:45
  • If you are learning SQL, I would also suggest that you learn better naming and typing conventions. Dates should not be stored as strings; they should be stored as dates. A column called "number" should not be stored as a string (IMHO); you should call it something else, such as "code" or actually use a number. – Gordon Linoff Sep 04 '16 at 14:22

1 Answers1

0

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
 );
Shushil Bohara
  • 5,556
  • 2
  • 15
  • 32
  • Oh I see that's why whenever I type Order it suggesting the word Order. Thanks for the help! I'm currently learning SQL/Databases – Da Phuc Sep 04 '16 at 13:44