Search code examples
mysqlsqlcreate-table

SQL Query Error message


I have this SQL Query

   CREATE TABLE items(
   partnum VARCHAR( 20 ) NOT NULL ,
   DESC VARCHAR( 50 ) 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?


Solution

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

    or rename it to e.g Description