I'm having trouble adding 1 to a column value in MySQL. I've used backticks on the column name and value isn't incrementing. Here is my query:
$update = $connectdb->prepare("UPDATE `strings` SET posted=posted, `response-comment`=`response-comment` + 1 WHERE `id`=?");
$update->execute(array($id));
Why isn't my query working? The value $id
is correct, the column response-comment
should increase by 1.
Try using this for your SQL statement (presuming strings
is the name of your table:
UPDATE `strings` SET `response-comment`=`response-comment` + 1 WHERE `id`=?
Be careful with tick marks If improperly coded you can end up with quotes which is going to transform you integer value into a string and thus changing the behavior of your request. Have you tried with out , just
response-comment = response-comment + 1`