Error: ER_PARSE_ERROR: You have an error in your SQL syntax;

在尝试使用SQL语句更新MySQL数据库时遇到了ER_PARSE_ERROR,原因是列名'desc'与MySQL的保留关键字冲突。解决方法是将列名'desc'替换为'a_desc',避免与系统命令混淆。更新后的正确SQL语句应为:update articles set title='百草院子', a_desc=NULL, content='不久之前', cate='1', created_at='2021-02-15 15:34:21.000', updated_at='2021-02-20 15:56:23.390' where id='5'。

在MySQL命令行使用sql语句进行更新操作时,
sql 语句

update article set title=\'百草院子\',desc=NULL,content=\'不久之前\',cate=\'1\',created_at=\'2021-02-15 15:34:21.000\',updated_at=\'2021-02-20 15:56:23.390\' where id=\'5\'

出现如下错误;
Error: ER_PARSE_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=‘从百草园到三味书屋’ content=‘不久之前’ where id=NULL’ at line 1
code: ‘ER_PARSE_ERROR’,
errno: 1064,
sqlMessage:
‘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=NULL,content=‘不久之前’,cate=‘1’,created_at=‘2021-02-15 15:34:21.000’,u’ at line 1’,
sqlState: ‘42000’,
index: 0,

原因

这个提示指的是语法错误
经过仔细检查,之所以报这个错误,是因为列名desc与mysql数据库中的保留字段重复,desc命令可以查看表结构的详细信息,降序排列数据。

解决方案:

修改sql语句,将desc换为其他名称,我这里将其修改为a_desc

update article set title=\'百草院子\',a_desc=NULL,content=\'不久之前\',cate=\'1\',created_at=\'2021-02-15 15:34:21.000\',updated_at=\'2021-02-20 15:56:23.390\' where id=\'5\'
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值