我正在尝试使用MySQL更新一个表上的多个行。我发现这是可能的,但我正在尝试将comments列的值递增给定的数量,但是尝试将其递增1实际上会将其递增3。
$increment = 1;
('UPDATE articles
SET comments = CASE
WHEN article_id in(1, 2) THEN comments + ' . $increment . '
END');有什么想法吗?谢谢,马特
发布于 2011-09-16 21:04:59
试试这个:
$query = "UPDATE articles SET comments = comments + " . $increment . " WHERE article_id IN (1, 2)";发布于 2011-09-16 21:05:39
我真的不明白为什么您当前的查询不能工作,但是当您使用这个查询时会发生什么呢?
UDPATE
articles
SET
comments=comments+'.$increment.'
WHERE
article_id IN (1,2)https://stackoverflow.com/questions/7445058
复制相似问题