0

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 ?

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Im looking for the multiple of X and C whereby X is another column not the sum.
@BKCapri . . . I adjusted the answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.