比如表中有字段userid,username,userage,usersex.
然后userid是自增字段即从0到128,不可为空.
userid为0~9的记录中其他字段是有值的,而10~19中其他字段为空.现在想把本来在userid为0~9的记录中的值,转移到userid为10~19的记录中,并删除0~9中的其他字段记录,该如何操作?

解决方案 »

  1.   

    update table1 a,table1 b set a.username=b.username,a.userage=b.userage,a.usersex=b.usersex where a.userid=b.userid+10
      

  2.   

    用个比较笨的办法,可以试下:
    update 表名 set userid = userid +200 where userid between 10 and 19update 表名 set userid = userid + 10 where userid between 0 and 9update 表名 set userid = userid - 210 where userid > 200
      

  3.   

    Use a temporary table is a best way.