0

Hi so I was wondering what the best way to add or subtract from a field in my table would be. The way I know it would work is if I query the value do the addition and then UPDATE the value.

I would rather include the addition as part of the update query like:

UPDATE users SET points = +10

Or something like that. Is it possible?

2 Answers 2

2

You just need to name the column on the right hand side of the = operator:

UPDATE `users` SET `points` = `points`+10

Since there is no WHERE clause this will give all users 10 more points then they currently have.

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

Comments

2

You can just do this:

UPDATE users SET points = points + 10

Comments

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.