Li haonan Li haonan - 14 days ago 6
MySQL Question

Mysql: Create table error

I try to create a table in mysql some error occured

mysql> create table order ( ID varchar(30) not null,
-> Cname varchar(100) not null,
-> name varchar(30),
-> Type varchar(30),
-> primary key(ID, Cname));
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 'order ( ID varchar(30) not null,
Cname varchar(100) not null,
name varchar(30),
' at line 1


I have checked for thousand time and I still find no error here.
Can anyone help me?

Answer

Its is because of the table name order. There is an order by reserved word. Change the table name and it will work fine.

If you want order as table name use back ticks around the table name. It will workfine