开发者

MySQL Batch increase value?

My client has asked me if I 开发者_C百科can update about 500 of his prices (increase by 10.00).

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

Thanks.


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

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

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

Note

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜