lisovaccaro
lisovaccaro

Reputation: 33956

How to make an addition to a MySQL column?

I want to make a "like" sort of button. It should basically +1 a value on the database called Likes. I can simply retrieve the value, do the addition and insert it again but I'm wondering if there is an easier way. Thanks

Upvotes: 0

Views: 207

Answers (2)

Vern
Vern

Reputation: 2413

If you need to keep track of a value, then it is necessary that you store it. In the alternative, you might want to consider using a normal text file if you don't already have a database running. Hope it helps.

Upvotes: 0

Explosion Pills
Explosion Pills

Reputation: 191729

UPDATE Likes SET likeCount = likeCount + 1 WHERE likeID = ?

Upvotes: 6

Related Questions