-4

我想通过一些偏移量更新我的表的列。现在我正在使用这个

SELECT FROM reward where id = xx
$score = id->score + 1;
then
UPDATE reward SET score = $score WHERE id = xx

有没有办法代替我可以做的两个查询UPDATE SET score = score + 1

4

2 回答 2

0

如果您希望增加一次尝试:

UPDATE reward SET score = score + 1 WHERE id = xx

如果要添加奖励:

UPDATE reward SET score = score + reward WHERE id = xx
于 2013-03-04T14:27:13.143 回答
0

如果您需要从另一个表中选择它,您可以这样做:

update reward set score = (select score from reward where id = xx) + 1 where id = xx

或者,如果您只需要将该分数加一:

UPDATE reward SET score = score + 1 WHERE id = xx
于 2013-03-04T14:29:55.510 回答