id    time   a
1            3
2            2
3            3
4            1
5            2
6      
7            2
我现在是按照时间排列 我想再加个条件 按照a排列 把a=3的放前面去  同时不要影响那些a=1.2位置
结果如下id    time   a
1            3
3           3
2           2
4            1
5            2
6      
7            2
 

解决方案 »

  1.   

    我原来是按照时间排列的 我想再加个条件把a=3的帖子给给放最上面 
    select * form table where a=3 order by time desc 
    和  
    select * form table where a!=3 order by time desc 2条语句的组合 改怎么写?
      

  2.   

    没时间帮你写出sql语句,有个建议先搜出a=3的,然后再搜出a!=3并按照time排序的,然后把后面的结果连接到a=3的结果后面楼主可以自己试着写一下,呵呵
      

  3.   

    请查 UNION 关键字select * form table where a=3 order by time desc
    UNION
    select * form table where a!=3 order by time desc 
      

  4.   


    还是不懂楼主究竟要怎么排列,说清楚点嘛???我想是很复杂的SQL语句。
      

  5.   

    lz是不是要达到的效果是 a=3的优先 但是1,2.。。按正常顺序?
    如果是的话,可以用 unionselect * from tb where a=3 
    union 
    select * from tb where a!=3 order by a