How to reverse the default ordering in Mysql?

前端 未结 5 1473
名媛妹妹
名媛妹妹 2020-12-20 18:29

In Mysql, when you execute a select SQL statement, there is a default ordering if you don\'t include a sorting clause, how to reverse the default ordering? Just add DE

5条回答
  •  南方客
    南方客 (楼主)
    2020-12-20 19:22

    If you want the data to come out consistently ordered, you have to use ORDER BY followed by the column(s) you want to order the query by. ASC is the default, so you don't need to specify it. IE:

    ORDER BY your_column
    

    ...is the equivalent to:

    ORDER BY your_column ASC
    

    ASC/DESC is on a per column basis. For example:

    ORDER BY first_column, second_column DESC
    

    ...means that the query will sort the resultset as a combination using the first_column in ascending order, second_column in descending order.

提交回复
热议问题