简体   繁体   English

更新mysql中的longtext字段

[英]Update longtext field in mysql

Im trying to update a longtext type field called 'comment' using a simple sql query in mysql client like this : 我试图像这样在mysql客户端中使用简单的sql查询来更新名为'comment'的longtext类型字段:

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

But i'm getting this error 但是我收到这个错误

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

Am i missing something ?, thanks in advance. 我错过了什么吗?,在此先感谢。

comment is a reserved word , if you want to have a table/field with that name, you have to quote it (or use the table.fieldname syntax, in case of a field). comment是一个保留字 ,如果要使用具有该名称的表/字段,则必须用引号引起来(或使用table.fieldname语法,如果是字段)。 default in mysql is the backtick for that, so: mysql中的default是它的背景,所以:

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

找到了,就解决了:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM