How to reverse the default ordering in Mysql?

前端 未结 5 1477
名媛妹妹
名媛妹妹 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条回答
  •  萌比男神i
    2020-12-20 19:26

    You can set a counter in your result fields and sort using it:

    SELECT *, @counter := @counter + 1 AS 'counter' FROM tableName, (SELECT @counter := 0) r ORDER BY counter DESC
    

    I think it will work as you want.

提交回复
热议问题