Sorting multiple fields in MySQL

后端 未结 2 403
轮回少年
轮回少年 2021-01-11 16:19

I have a table with 2 fields DATE and IMPORTANCE. Now I want to sort both these fields in DESCENDING ORDER so that the rows are ordered by IMPORTANCE for EACH DATE. For ex

相关标签:
2条回答
  • 2021-01-11 16:46
    SELECT * FROM yourtable
    ORDER BY `DATE` DESC, `IMPORTANCE` DESC
    
    0 讨论(0)
  • 2021-01-11 17:01

    You can add as many fields to ORDER BY as you want.

    That'd be something like:

    SELECT * FROM table ORDER BY `date` DESC, `importance` DESC
    
    0 讨论(0)
提交回复
热议问题