在没有 PHP 的 MYSQL 上将表字段更新为其值加上一个常量
我想在 MYSQL
中执行 UPDATE
,我在其中获取一个字段值,添加一个常量并将新值保存在同一字段中.
I would like to perform an UPDATE
in MYSQL
in which I take a field value, add a constant and save the new value in the same field.
假设我们在一个名为 aTable
的表中有一个名为 OldValue
的列.
Let's assume that we have a column called OldValue
in a table called aTable
.
伪代码可能是:
UPDATE aTable SET OldValue = OldValue + 220 WHERE someField = someValue
你知道我该怎么做吗?我想使用单个查询(在某些管理面板上)而不制作 php
脚本.(当然,在那种情况下答案很简单.)
Do you have any idea on how I could do that? I would like to use a single query (on some administration panel) without making a php
script. (Of course, in that case the answer is quite simple.)
推荐答案
你的代码可以运行.
查看它在 SQLFiddle 中的工作.
我一字不差地使用了您的确切查询,除了用实际值代替someValue".
I used your exact query verbatim, except for substituting a real value for "someValue".
相关文章