Answer the question
In order to leave comments, you need to log in
How to change value in MySQL table if...?
How to change the value of the dle_users table, the balance column, depending on the value of the user_group column
That is, if the value of the user_group column = 3, then the value of the balance column should be added the number 10
If the value of the user_group column = 4, then the value of the balance column should be added the number 40. The value in the balance column can be anything and a number must be added to it depending on the number in the user_group column.
Thanks in advance for your help in resolving this issue.
Answer the question
In order to leave comments, you need to log in
Try like this:
UPDATE mytable
SET balance =
(
CASE
WHEN user_group = 3 THEN balance + 10
WHEN user_group = 4 THEN balance + 40
END
)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question