select * from table where id in(10,6,9,20)
这样的话 出来的数据是 根据id升序排的请教下 怎么根据 in() 里的顺序的倒序来排就是
20
9
6
10
这样排
作用就是 记录文章的浏览历史
后台
asp
access数据库

解决方案 »

  1.   

    select * from table where id in(10,6,9,20) order by id desc
      

  2.   


    select * 
    from table 
    where id in(10,6,9,20)
    order by id desc
      

  3.   

    select * from table where id in(10,6,9,20)
    order by charindex(',' + cast(id as nvarchar(20)) + ',' ,',10,6,9,20,') desc
      

  4.   


    貌似这样比较麻烦吧, LZ使用插入时间desc 排序是不是更好些?select * 
    from table 
    where id in(10,6,9,20)
    order by insertdate desc --如果有插入时间的话。
      

  5.   

    access,nvarchar可能需要修改下,自己修改,我忘了
      

  6.   

    恩 mssql下没问题,现在是 access下有问题, 我也不会,麻烦了。
      

  7.   

    select * from table where id in(10,6,9,20)
    order by charindex(',' + cast(id as varchar(50)) + ',' ,',10,6,9,20,') desc
      

  8.   

    access里用instr函数,select * from table 
    where id in(10,6,9,20)
    order by Instr("10,6,9,20",","+cstr(id)) desc