mysql更新查询失败

时间:2010-11-29 18:45:34

标签: php mysql

我的查询代码是:

$query = mysql_query("UPDATE books SET read = 'y' WHERE id = 2") or die(mysql_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 'read = 'y' WHERE id = 2' at line 1

1 个答案:

答案 0 :(得分:3)

read是MySQL中的保留关键字。用反引号括起来:

UPDATE books SET `read` = 'y' WHERE id = '2'

有关保留关键字的列表,请参阅http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html