Update a Table Field to its Value Plus a Constant on MYSQL w/o PHP(在没有 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".
这篇关于在没有 PHP 的 MYSQL 上将表字段更新为其值加上一个常量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在没有 PHP 的 MYSQL 上将表字段更新为其值加上一个常量
基础教程推荐
- 在多列上分布任意行 2021-01-01
- 二进制文件到 SQL 数据库 Apache Camel 2021-01-01
- 如何在 SQL 中将 Float 转换为 Varchar 2021-01-01
- 如何根据该 XML 中的值更新 SQL 中的 XML 2021-01-01
- mysql选择动态行值作为列名,另一列作为值 2021-01-01
- 在 MySQL 中:如何将表名作为存储过程和/或函数参数传递? 2021-01-01
- 什么是 orradiag_<user>文件夹? 2022-01-01
- 表 './mysql/proc' 被标记为崩溃,应该修复 2022-01-01
- oracle区分大小写的原因? 2021-01-01
- MySQL 中的类型:BigInt(20) 与 Int(20) 2021-01-01
