Table:
+-------+---------------------+-------+
|    id | modify_date         |   top |
+-------+---------------------+-------+
|     1 | 2008-04-02 16:51:40 |     0 |
|     2 | 2008-04-02 16:51:40 |     0 |
|     9 | 2008-04-02 19:19:04 |     1 |
|    15 | 2008-04-08 17:54:11 |     0 |
|    16 | 2008-04-08 16:19:07 |     0 |
|    17 | 2008-04-08 16:19:11 |     0 |
|    18 | 2008-04-08 16:19:17 |     0 |
+-------+---------------------+-------+select id, modify_date, top from tableA order by top and modify_date desc
这句只能order by top,但date就不是desc
+-------+---------------------+-------+
|    id | modify_date         |   top |
+-------+---------------------+-------+
|     9 | 2008-04-02 19:19:04 |     1 |
|     1 | 2008-04-02 16:51:40 |     0 |
|    42 | 2008-04-08 19:39:12 |     0 |
|    41 | 2008-04-08 18:54:55 |     0 |
|    27 | 2008-04-08 17:54:11 |     0 |
|    26 | 2008-04-08 16:20:14 |     0 |
|    24 | 2008-04-08 16:20:00 |     0 |
|    23 | 2008-04-08 16:19:53 |     0 |
|    22 | 2008-04-08 16:19:46 |     0 |
|    21 | 2008-04-08 16:19:40 |     0 |
|    20 | 2008-04-08 16:19:33 |     0 |
+-------+---------------------+-------+
请问怎样先排top 1,然后order by modify_date desc ?
感谢

解决方案 »

  1.   

    select id, modify_date, top 
    from tableA 
    order by top , modify_date desc[align=center]====  ====
    [/align]
      

  2.   

    mysql> SELECT * FROM tablea order by top, modify_date desc;+----+---------------------+-----+
    | id | modify_date         | top |
    +----+---------------------+-----+
    |  5 | 2008-04-09 13:42:37 |   0 |
    |  4 | 2008-04-05 13:42:37 |   0 |
    |  3 | 2008-04-04 13:42:37 |   0 |
    |  1 | 2008-04-02 13:42:37 |   0 |
    |  2 | 2008-04-03 13:42:37 |   1 |
    +----+---------------------+-----+不行啊,这样排了date先我是想top的1排先,然后后面排date+----+---------------------+-----+
    | id | modify_date         | top |
    +----+---------------------+-----+
    |  2 | 2008-04-03 13:42:37 |   1 |
    |  5 | 2008-04-09 13:42:37 |   0 |
    |  4 | 2008-04-05 13:42:37 |   0 |
    |  3 | 2008-04-04 13:42:37 |   0 |
    |  1 | 2008-04-02 13:42:37 |   0 |
    +----+---------------------+-----+
    这样
      

  3.   

    SELECT * FROM tablea order by top desc , modify_date desc;兄弟,你也没说 top 也要 按降序排阿 [align=center]====  ====
    [/align]
      

  4.   

    特此介绍一下结贴的方法如果您问题已经得解决,请您及时结帖给分,以感谢帮助您的朋友。 结帖方法:点击版面右上方或右下方 [管理] ,进入页面后就可以输入密码,分别给分,结帖。 
     或参考:
    http://www.csdn.net/help/over.asp
    http://topic.csdn.net/u/20080110/19/7cb462f1-cac6-4c28-848e-0a879f4fd642.html
    =============================================================================
    问题解决,请及时结贴。  
     正确结贴方法:    
     管理帖子-->给分-->输入密码-->结贴[align=center]====  ====
    [/align]