数据库里面的一张表,有个字段是int类型的。
我想将这个字段加5,要先把这个字段读取到,然后加5,然后再更新 这么三个动作,
有没有简便的方法呢,不管这个字段值是多少我用一个语句就能搞定呢

解决方案 »

  1.   

    读取到这个字段的值,然后+10
    update 表名 set 字段=字段+10后的值
      

  2.   

    update yourTable set 这个字段=这个字段+5
      

  3.   

    update table set 字段 = 字段+5;
      

  4.   

    update 表名  set 字段名 = 字段名+5 
      

  5.   

    当日可以的,update a set a.F1=(select b.F1 from b where a.FK1=b.FK1) where exists(select b.F1 from b where a.FK1=b.FK1)或者update a A set A.F1=B.F1 from b B where A.FK1=B.FK1
    都是可以的
      

  6.   

    update table a set a.age=a.age+5