Reputation: 558
I would like to add a value to every row in a table. Using a fixed value would give me the following query
UPDATE your_table SET displayorder = displayorder + C
What would be the right way to run a similar query such that
UPDATE your_table SET displayorder = displayorder + X(C)
Whereby C is a constant and X is the value of another column of the same row ? How do I get X which is the value of another column and how do I multiply it by C then add to an existing value ?
Upvotes: 0
Views: 29
Reputation: 1270091
You would just multiply them together:
UPDATE your_table
SET displayorder = displayorder + X * C;
In most programming languages, *
is used for multiplication. Parentheses are just used to group expressions.
Upvotes: 2