如何一次订购三列,这些列基于不同列的排序

时间:2017-08-31 11:07:51

标签: mysql

我有下表

    category_name      category_order  subcategory_order  startdate   enddate     
    -----------------  --------------  -----------------  ----------  ------------
    Adult                           1             (NULL)  (NULL)      (NULL)      
    Fun-Jokes                       6             (NULL)  (NULL)      (NULL)      
    Hollywood                       5                  3  (NULL)      (NULL)      
    Tollywood                  (NULL)                  2  (NULL)      (NULL)      
    Bollywood                  (NULL)                  1  (NULL)      (NULL)      
    Movies                          4             (NULL)  (NULL)      (NULL)      
    For Sister                 (NULL)                  3  (NULL)      (NULL)      
    For Dad                    (NULL)                  2  (NULL)      (NULL)      
    For MOM                    (NULL)                  1  (NULL)      (NULL)      
    Birthday                        3             (NULL)  (NULL)      (NULL)      
    Festivals                       2             (NULL)  (NULL)      (NULL)      
    Diwali                     (NULL)             (NULL)  2017-10-01  2017-10-10  
    Holi                       (NULL)             (NULL)  2017-02-15  2017-02-15 
    Christmas                  (NULL)             (NULL)  2017-12-25  2017-12-31  
    Ganapati Festival          (NULL)             (NULL)  2017-08-25  2017-08-31 

现在我想要这样的输出

    category_name      category_order  subcategory_order  startdate   enddate     
    -----------------  --------------  -----------------  ----------  ------------
    Adult                           1             (NULL)  (NULL)      (NULL)      
    Festivals                       2             (NULL)  (NULL)      (NULL)   
    Ganapati Festival          (NULL)             (NULL)  2017-08-25  2017-08-31     
    Diwali                     (NULL)             (NULL)  2017-10-01  2017-10-10  
    Christmas                  (NULL)             (NULL)  2017-12-25  2017-12-31  
    Holi                       (NULL)             (NULL)  2017-02-15  2017-02-15  
    Birthday                        3             (NULL)  (NULL)      (NULL)      
    For MOM                    (NULL)                  1  (NULL)      (NULL)      
    For Dad                    (NULL)                  2  (NULL)      (NULL)      
    For Sister                 (NULL)                  3  (NULL)      (NULL)      
    Movies                          4             (NULL)  (NULL)      (NULL)      
    Bollywood                  (NULL)                  1  (NULL)      (NULL)      
    Tollywood                  (NULL)                  2  (NULL)      (NULL)      
    Hollywood                  (NULL)                  3  (NULL)      (NULL)      
    Hollywood                       5             (NULL)  (NULL)      (NULL)      
    Fun-Jokes                       6             (NULL)  (NULL)      (NULL)   

表示我希望按子类别顺序在子类别中排序,在子类别中按日期排序,或者如果类别具有日期,则按子类别顺序排序 注意:日期排序首先基于当前日期,稍后再保留。

0 个答案:

没有答案