MySQL 更新查询中的增量值 [英] Increment value in MySQL update query
本文介绍了MySQL 更新查询中的增量值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经制作了这个代码来给出 +1 分,但它不能正常工作.
I have made this code for giving out +1 point, but it doesn't work properly.
mysql_query("
UPDATE member_profile
SET points= ' ".$points." ' + 1
WHERE user_id = '".$userid."'
");
$points
变量是用户现在的点数.我希望它添加一个.例如,如果他有 5 分,它应该是 5+1 = 6,但事实并非如此,它只是变为 1.
The $points
variable is the user's points right now. I want it to add one to it. So example if he had like 5 points, it should be 5+1 = 6, but it doesn't, it just changes to 1.
我做错了什么?
推荐答案
你也可以这样做:
mysql_query("
UPDATE member_profile
SET points = points + 1
WHERE user_id = '".$userid."'
");
这篇关于MySQL 更新查询中的增量值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文