通过减去值来更新列 [英] update a column by subtracting a value
本文介绍了通过减去值来更新列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正试图提出一个将更新points
的MySQL查询...我可以做这样的事情吗?
I'm trying to come up with a MySQL query that will update points
... Can I do something like this?
UPDATE `a75ting`.`username` SET `points` = '`points` - 5'
推荐答案
UPDATE a75ting.username
SET points = points - 5
通过将单引号放在点-5"周围,可以将该表达式转换为纯文本字符串.不用引号就可以使MySQL看到您正在引用一个字段(点),并从其当前值中减去5.
by putting the single quotes around the "points -5", you converted that expression into a plaintext string. Leaving it without the quotes lets MySQL see you're referring to a field (points) and subtracting 5 from its current value.
这篇关于通过减去值来更新列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文