你是要把1、2的state和3、4的交换吗?

解决方案 »

  1.   

    不是很理解你的意思,我认为两个简单的update的语句就可以了阿
    update aaa
    set state='2'
    where state='1';
    update aaa
    set state='1'
    where state='2';
      

  2.   

    把,state为1的改为state=2,且把state=2的改为state=1;
      

  3.   

    回:f3611018(明月) ,你的结果是,state都为1
      

  4.   

    update aaa set state=decode(state,'1','2','2','1')
      

  5.   

    请:rrxxpp(ren)解释decode(state,'1','2','2','1')什么意思
      

  6.   

    decode。如果state的值为'1',那么返回'2',如果state的值为'2',返回'1'.
      

  7.   

    相当一个IF判断,如果state为1就是2,如果为2就是1
      

  8.   

    update aaa
    set
    state=(decode(state,'1','2','2','1',null)
      

  9.   

    sorry:
    update aaa
    set
    state=(decode(state,'1','2','2','1',null))
      

  10.   

    表aaa里面还有记录(5,'3'),上面的代码造成了这样的结果(5,);即'3'变成了null
      

  11.   

    我不想改变除了state为1和2 的其他记录
      

  12.   

    update aaa
    set
    state=(decode(state,'1','2','2','1',null))
    where id=1 or id=2
      

  13.   

    sorry:
    update aaa
    set
    state=(decode(state,'1','2','2','1',null))
    where state='1' or state='2'
      

  14.   

    update aaa
    set
    state=decode(state,'1','2','2','1');
      

  15.   

    update aaa
    set
    state=decode(state,'1','2','2','1',state);
      

  16.   

    update aaa
    set
    state=decode(state,'1','2','2','1',state)
    where state in ('1','2');
      

  17.   

    update aaa
    set state='2'
    where state='1';
    update aaa
    set state='1'
    where state='2';
    我认为对的