create table a
(classid varchar(5),
sort int)
insert a select 'a01',1
union select 'a02',2
union select 'a03',3
union select 'a04',4select * into # from a
update t set sort=x.sort from a t,a x where x.classid='a03' and t.classid='a02'
update t set sort=b.sort from a t,# b where b.classid='a02' and t.classid='a03'
select * from a

解决方案 »

  1.   

    数据库里的记录不一定要按照某个顺序排序啊,你要按照一定的规则排序,可以用SQL语句来实现的。如:
    select * from 表 order by 字段A
    如果你一定要将
    A01 1
    A02 2
    A03 3
    A04 4
    排成
    A01 1
    A02 3
    A03 2
    A04 4
    有什么意义呢?
      

  2.   

    我要用sort这个字段作为排序的准则
    select * from 表 order by sort