MySQL批处理增加价值? [英] MySQL Batch increase value?

查看:98
本文介绍了MySQL批处理增加价值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的客户问我是否可以更新他的价格中的约500(增加10.00).

My client has asked me if I can update about 500 of his prices (increase by 10.00).

所有产品都存储在MySQL表中,谁能给我一个可以执行此操作的示例SQL查询?

The products are all stored in a MySQL table, can anyone give me an example SQL query that will do this?

谢谢.

推荐答案

此示例将更新CategoryID 27的所有价格:

This is an example that will update all the prices for CategoryID 27:

update MyTable
set Price = Price + 10
where CategoryID = 27

在运行 UPDATE 查询之前,为此,请通过运行 <具有相同WHERE子句的c1> 查询并检查结果:

Before you run an UPDATE query like this, make sure you are going to update the right records by running a SELECT query with the same WHERE clause and examining the results:

select *
from MyTable
where CategoryID = 27

注意

以上假设没有价格历史记录被维护.您将必须检查表结构以了解是否是这种情况.如果要维护价格历史记录,则需要采用不同的方法,具体取决于架构的结构.如果您让我们知道您的架构是什么,我们可以更加具体.

The above assumes there is no price history being maintained. You will have to examine the table structure to know whether this is the case or not. If price history is being maintained, you will need to take a different approach, depending upon how the schema is structured. IF you let us know what your schema is, we can be more specific.

这篇关于MySQL批处理增加价值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆