How to update field to add value to existing value?

前端 未结 7 2031
迷失自我
迷失自我 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 18:53

    well '+' is an operator so u need to provide the parameter it requires. '+' operator is an binary operator thus we need to provide two parameters to it with the syntax

     value1+value2
    

    though it may take parameters of many data types by writing '+7' you are only sending a String value "+7" replacing your previous value

    so u better use

    UPDATE table SET credit = '+7' WHERE id='1'
    

    don't confuse '+' operator with other increment operators

提交回复
热议问题