如何将一张表内的 某一列数值  全部减半?这一列数值的全都是不一样的例如 会员表中的会员积分  每个数值都是不一样的  怎样可以把这个数值 全部减半

解决方案 »

  1.   

    --更新
    update tb set colA/2 where --条件。
    --查找
    select colA from tb where -- 条件。
      

  2.   

    --更新
    update tb set colA/2 where --条件。
    --查找
    select colA/2 from tb where -- 条件。
    修改一下
      

  3.   

    你照着句子翻译一下就好了,
    第一句,update 更新 tb 表名,set 设置 colA 列值 /2 减半
    如果没条件的话,就不要加where 如果有条件,就加个where 后面跟你所要更新的条件
    比如说 你要修改哪一行的数据。把行号 id = 。。 写出来
    第二句你自己翻译把
    查询
      

  4.   

    update tb set colA/2 where
      

  5.   

    update tb set colA=colA/2 
    --应该是这样
    --这句话的意思是修改表TB的COLA列,使它变为原来COLA的一半 
      

  6.   


    declare @t table (colA int)
    insert into @t
    select 2 union all
    select 3 union all
    select 4 union all
    select 5 union all
    select 6 union all
    select 7update @t set colA=colA/2
    select * from @t
    /*
    colA
    -----------
    1
    1
    2
    2
    3
    3
    */
    --我们再定义一个表变量
    declare @m table (colA decimal(4,2))
    insert into @m
    select 2 union all
    select 3 union all
    select 4 union all
    select 5 union all
    select 6 union all
    select 7update @m set colA=colA*0.5
    select * from @m
    /*
    colA
    ---------------------------------------
    1.00
    1.50
    2.00
    2.50
    3.00
    3.50
    */