有个表,2个字段,内容:A1  1
A2  2
A3  3想写个语句,怎么变成
A1 3
A2 1
A3 2A1 2
A2 3
A3 1
谢谢!!

解决方案 »

  1.   

    A1 3
    A2 2
    A3 1
      

  2.   


    create table zh
    (c1 varchar(5), c2 int)insert into zh
     select 'A1', 1 union all
     select 'A2', 2 union all
     select 'A3', 3
     update zh
     set c2=case c2 when 1 then 3
                    when 2 then 1
                    when 3 then 2 end
     
    select c1,c2 from zh/*
    c1    c2
    ----- -----------
    A1    3
    A2    1
    A3    2(3 row(s) affected)
    */