有一个表student里有一些记录,我想让name='abc'这条记录在第一条显示,其它记录在后面显示,我应该怎么写这条查询语句?谢谢了

解决方案 »

  1.   

    select * from student where name='abc'
    union all
    select * from student where name!='abc'或者用case when来做。
      

  2.   

    select * from tt order by if(name='abc',1,2)
      

  3.   

    or
    select *,if(name='abc',1,2) as sx from tt order by sx
      

  4.   

    select *,1 as sno
    from student
    where name='abc'
    union all
    select *,2 as sno
    from student
    where name!='abc' 
    order by sno[align=center]====  ====
    [/align]
      

  5.   

    select *
    from student
    order by IF(name='abc',0,1)[align=center]====  ====
    [/align]