select * from table1
where table1.aa in (23,68,50,30)想查出的结果也是按表中aa字段中的(23,68,50,30)
这个顺序排列,不知道如何解决。

解决方案 »

  1.   

     select   *   From   table1   Where   aa   in   (23,68,50,30)   order   by   charindex(','+rtrim(cast(aa   as   varchar(10)))+','   ,   ',23,68,50,30,')   
      

  2.   

    好像不行吧,能不能这样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
      

  3.   

    试过一楼的方法可行在sql server2000试过没有问题
    谢谢
      

  4.   


    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,')