select * From table1 Where aa in (23,68,50,30) order by charindex(','+rtrim(cast(aa as varchar(10)))+',' , ',23,68,50,30,')
好像不行吧,能不能这样select * from table1 where table1.aa = 23 union all select * from table1 where table1.aa = 68 union all select * from table1 where table1.aa =50 union all select * from table1 where table1.aa =30
试过一楼的方法可行在sql server2000试过没有问题 谢谢
create table table1 ( username varchar(50) , aa int )insert into table1(username,aa) values('zhang',100) insert into table1(username,aa) values('sun',80) insert into table1(username,aa) values('li',70) insert into table1(username,aa) values('lin',99) insert into table1(username,aa) values('wang',88) insert into table1(username,aa) values('he',55) insert into table1(username,aa) values('lian',44) insert into table1(username,aa) values('yao',22)select * from table1select * From table1 Where aa in (88,70,99,55) order by charindex(','+rtrim(cast(aa as varchar(10)))+',' , ',88,70,99,55,')
where table1.aa = 23
union all
select * from table1
where table1.aa = 68
union all
select * from table1
where table1.aa =50
union all
select * from table1
where table1.aa =30
谢谢
create table table1
(
username varchar(50)
, aa int
)insert into table1(username,aa) values('zhang',100)
insert into table1(username,aa) values('sun',80)
insert into table1(username,aa) values('li',70)
insert into table1(username,aa) values('lin',99)
insert into table1(username,aa) values('wang',88)
insert into table1(username,aa) values('he',55)
insert into table1(username,aa) values('lian',44)
insert into table1(username,aa) values('yao',22)select * from table1select * From table1 Where aa in (88,70,99,55) order by charindex(','+rtrim(cast(aa as varchar(10)))+',' , ',88,70,99,55,')