更新mysql中的longtext字段

时间:2016-08-09 13:51:59

标签: mysql

我试图在mysql客户端中使用简单的SQL查询来更新名为'comment'的longtext类型字段,如下所示:

Update mytable set comment='Test' where id = 1;

但是我收到了这个错误

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 'comment='Test' where id = 1' at line 1

我错过了什么吗?,提前谢谢。

2 个答案:

答案 0 :(得分:2)

commentreserved word,如果您想要一个具有该名称的表/字段,则必须引用它(或使用table.fieldname语法,如果是字段)。 mysql中的默认值是反引号,所以:

 update mytable set `comment`='Test' where id = 1;

答案 1 :(得分:0)

找到它,它得到了解决:

update mytable as a set a.comment='Test' where id = 1;