0

I can't seem to find the reason why Mysql keeps failing to create the following table. Error 1064 displayed

" 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 'order ( orderId int not null auto_increment primary key,
clientId int not nu' at line 1"

CREATE TABLE order (
  orderId int not null auto_increment primary key,
  clientId int not null,
  delivery boolean not null default 0,
  isOpen boolean not null default 1,
  foreign key (clientId) references user (uid),
  createdAt timestamp not null default current_timestamp,
  updatedAt timestamp not null default current_timestamp on update current_timestamp);

I tried removing the foreign key to see if it was the issue, but it didn't work. Couldn't find anything online yet to the problem.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Milan
  • 75
  • 1
  • 4
  • Search for 'error 1064', no one is going to do your homework. – nckbrz Nov 26 '17 at 01:39
  • Or... maybe they will – nckbrz Nov 26 '17 at 01:40
  • Why is it no one can ever follow instructions and read the documentation? Or at least do a basic search on the error message, which would have shown you that the majority of the time this is caused by using a reserved word as a table or column name? Seriously, it's OK to need help sometimes, but please don't be helpless. A Google search is the **very least effort** you can put in to try to solve the problem yourself, and you didn't even do that much. – Ken White Nov 26 '17 at 02:22

1 Answers1

2

ORDER is a reserved word

try using backtick ("`")

CREATE TABLE `order` (
Mate
  • 4,976
  • 2
  • 32
  • 38
  • finaaally!!! thank you so much, im new to mysql so didn´t knew there were some reserverd words. Thank you so much! – Milan Nov 26 '17 at 01:46