如何在Mysql中反转默认顺序? [英] How to reverse the default ordering in Mysql?

查看:204
本文介绍了如何在Mysql中反转默认顺序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Mysql中,当执行select SQL语句时,如果不包括排序子句,则存在默认顺序,如何反转默认顺序?只需添加DESC?

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 DESC?

推荐答案

如果要使数据一致地排序,则必须使用ORDER BY,后跟要作为查询排序依据的列. ASC是默认设置,因此您无需指定它. IE浏览器:

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

...等效于:

ORDER BY your_column ASC

ASC/DESC基于每一列.例如:

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

ORDER BY first_column, second_column DESC

...表示查询将使用first_column升序,second_column降序将结果集作为组合排序.

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

这篇关于如何在Mysql中反转默认顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆