How to do an update always adding + 1 in mysql

3

Hello,

How do I update a mysql column by always inserting +1 every new update? And how do you get -1 from the same column?

I've tried this:

"UPDATE tb_comment SET good=+1 WHERE id=:idComment"

Only you entered 1, did not continue counting 1..2..3..4 according to the updates I gave ..

And to get 1 record I tried this:

UPDATE tb_comment SET good=-1 WHERE id=:idComment

And I failed miserably

    
asked by anonymous 17.01.2016 / 21:51

1 answer

2

Solved !!

Just do the following:

"UPDATE tb_comment SET good=good+1 WHERE id=:idComment"
    
17.01.2016 / 21:59