Take the 2-minute tour ×

This question already has an answer here:

I have this SQL Query

   CREATE TABLE items(
   partnum VARCHAR( 20 ) NOT NULL ,
   price INT( 11 ) NOT NULL ,
   src VARCHAR( 25 ) NOT NULL ,
   PRIMARY KEY (  `partnum` )

It's meant to create a table in my database but I keep receiving the following error:

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 'desc varchar(50) NOT NULL,
 price int(11) NOT NULL,
 src varchar(25) NOT NULL,
 ' at line 3 

Any idea what i'm doing wrong?

share|improve this question

marked as duplicate by Martin Smith, marc_s, bluefeet, Jonathan Leffler, john.k.doe Apr 14 '13 at 17:50


Desc is a reserved word (as in order by foo desc) and needs to be in back ticks. –  Martin Smith Apr 14 '13 at 11:49
Doh, how did I miss that! @MartinSmith wasn't a duplicate but thanks –  user182 Apr 14 '13 at 11:56
add comment

1 Answer

up vote 0 down vote accepted

Desc is a reserved keyword it cant used as a name of column, put it in quotes

or rename it to e.g Description

share|improve this answer
putting a keyword in quotes isn't going to solve the problem –  Ejay Apr 14 '13 at 12:03
@Ejay I believe it is. HAve you tried it and it fails? –  apomene Apr 14 '13 at 12:07
yes I've tried it. I think you're mixing up backticks and quotes :) –  Ejay Apr 14 '13 at 12:09
add comment
