简体   繁体   English

MySQL错误1064,带有UPDATE,但查询看起来正确

[英]MySQL Error 1064 with UPDATE, but query looks correct

Im not sure whats going on here 我不确定这里发生了什么

mysql> update messages set read=1 where id=4;
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 'read=1 where id=4' at line 1

mysql> show columns from messages;
+-------------------+---------------+------+-----+---------+----------------+
| Field             | Type          | Null | Key | Default | Extra          |
+-------------------+---------------+------+-----+---------+----------------+
| id                | int(11)       | NO   | PRI | NULL    | auto_increment |
| account_id        | varchar(255)  | NO   |     | NULL    |                |
| subject           | varchar(2048) | NO   |     | NULL    |                |
| message           | text          | NO   |     | NULL    |                |
| message_id        | int(11)       | NO   |     | 0       |                |
| read              | int(11)       | NO   |     | 0       |                |
| replied           | int(11)       | NO   |     | 0       |                |
| priority          | int(11)       | NO   |     | 0       |                |
| topic             | int(11)       | NO   |     | 0       |                |
| user_deleted      | int(11)       | NO   |     | 0       |                |
| created           | datetime      | NO   |     | NULL    |                |
| modified          | datetime      | NO   |     | NULL    |                |
| to_user_id        | int(11)       | NO   |     | 0       |                |
| recipient_deleted | int(11)       | NO   |     | 0       |                |
| recipient_read    | int(11)       | NO   |     | 0       |                |
+-------------------+---------------+------+-----+---------+----------------+
15 rows in set (0.00 sec)

Any ideas on how I can update the read column of the messages table? 关于如何更新邮件表的读取列的任何想法?

您可以在下面尝试-您需要使用back tick``作为保留关键字

update messages set `read`=1 where id=4;

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

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