This question already has answers here:
MySQL Syntax Error “right syntax to use near 'desc” [duplicate]
                                
                                    (2个答案)
                                
                        
                                6年前关闭。
            
                    
我有这个SQL查询

   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` )
   );


本来是要在数据库中创建一个表,但我仍然收到以下错误:

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


知道我在做什么错吗?

最佳答案

Desc是保留关键字,不能用作列名,用引号引起来

或将其重命名为例如Description

关于mysql - SQL查询错误消息,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15998703/

10-09 01:37
查看更多