Kyle
Kyle

Reputation: 3042

How would I globally add +1 to a table in mysql?

There was a problem with an sql server and my voting system set back people 1 day. I want to make it up to them and give them 1 point increase to make up for the loss.

How would I go about doing that? I was thinking of this but I don't think it would work..

SELECT votepoints FROM vsystem where votepoints=votepoints+1

Upvotes: 0

Views: 56

Answers (4)

Adonais
Adonais

Reputation: 1292

No. What you are saying is like search where the result equals the result plus 1. That won't be true.

You can UPDATE your table:

update vsystem set votepoints = votepoints + 1

...or get the results + 1 (without modifying the table):

select (votepoints + 1) as voteplus from vsystem

Upvotes: 3

FatherStorm
FatherStorm

Reputation: 7183

UPDATE vsystem SET votepoints=votepoints+1;

Upvotes: 1

Jordan Running
Jordan Running

Reputation: 106037

If you want to do a one-time fix, just do:

UPDATE vsystem
SET votepoints = votepoints + 1

This will add 1 to the votepoints column for every row in the vsystem table.

Upvotes: 2

ts.
ts.

Reputation: 10709

UPDATE vsystem SET votepoints=votepoints+1

Upvotes: 3

Related Questions