How to update field to add value to existing value?

前端 未结 7 2048
迷失自我
迷失自我 2021-01-03 18:11

How to update field to add value to existing value?
For example I have

Table name: table

id   credit
1      4
2      5
3      3
         


        
7条回答
  •  爱一瞬间的悲伤
    2021-01-03 19:02

    Simply use credit = credit + 7 instead of credit = '+7' in UPDATE statement

    UPDATE tablename SET credit = credit + 7 WHERE id = 1
    

    See this SQLFiddle

提交回复
热议问题