我在向 MySQL 中的列值添加 1 时遇到问题。我在列名上使用了反引号,并且值没有递增。这是我的查询:
$update = $connectdb->prepare("UPDATE `strings` SET posted=posted, `response-comment`=`response-comment` + 1 WHERE `id`=?");
$update->execute(array($id));
为什么我的查询不起作用?值 $id
正确,response-comment
列应增加 1。
最佳答案
尝试将其用于您的 SQL 语句(假设 strings
是您的表的名称:
UPDATE `strings` SET `response-comment`=`response-comment` + 1 WHERE `id`=?
关于php - MySQL - 将 1 添加到名称在反引号中的列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21086198/