简体   繁体   中英

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 :

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). default in mysql is the backtick for that, so:

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

找到了,就解决了:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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