有表T1
数据如下
id    name
578   a
458   b
1     c
1024  d
5878  e我从页面上把id传过来,查询的时候怎么让我传过的数据总是排在第一位上比如我传id=1024
那第一条数据就是 
id    name
1024  d
578   a
458   b
1     c
5878  e
这样了,其他的无所谓排在那了

解决方案 »

  1.   

    ORDER BY CASE WHEN id=@传过来的ID THEN 0 ELSE 1 END
      

  2.   

    select * from sysobjects where name ='sysfiles1'
    union all
    select * from sysobjects where name<>'sysfiles1'
      

  3.   

    ORDER BY CASE WHEN id=@传过来的ID THEN 0 ELSE 1 END
      

  4.   

    ORDER BY CASE WHEN id=@传过来的ID THEN 0 ELSE 1 END
      

  5.   

    笨点的办法,数据库中加个字段,记录时间不就可以了
    Order By 日期 DESC