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
(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
select * from 表 order by 字段A
如果你一定要将
A01 1
A02 2
A03 3
A04 4
排成
A01 1
A02 3
A03 2
A04 4
有什么意义呢?
select * from 表 order by sort