php DESC 在 SQL 中做什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11242055/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What does DESC do in SQL?
提问by Emmett
I am confused as to what the word 'DESC' does? What is it's purpose? Could you maybe provide other example, thank you!
我对“DESC”这个词的作用感到困惑?它的目的是什么?能否提供其他例子,谢谢!
$result = mysql_query("SELECT *, ROUND(score/(1+(losses/wins))) AS performance FROM images ORDER BY ROUND(score/(1+(losses/wins))) DESC LIMIT 0,10");
Edit: Realised this was a dumb question, should of used Google, I now know the answer stop attacking me guys I get it.
编辑:意识到这是一个愚蠢的问题,应该使用谷歌,我现在知道答案停止攻击我,我明白了。
回答by
You can order your records in ascending or descending order. The default is ASCENDING, which is shortened to ASCin SQL syntax. The opposite is of course DESCENDING, which is shortened to DESC.
您可以按升序或降序对记录进行排序。默认值为 ASCENDING,ASC在 SQL 语法中缩写为。相反的当然是 DESCENDING,简称为DESC.
For example,
例如,
SELECT * FROM images ORDER BY id ASC
This might give:
这可能会给出:
id | image
---+-----------
1 | bird.png
2 | flower.png
However
然而
SELECT * FROM images ORDER BY id DESC
Would give:
会给:
id | image
---+-----------
2 | flower.png
1 | bird.png
回答by verisimilitude
DESCsorts the resultset in descending order of the column specified, as opposed to ascending ASCwhich is the default
DESC按指定列的降序对结果集进行排序,而不是ASC默认升序
回答by sudocode
It says "sort in descending order".
它说“按降序排序”。
It is an optional keyword you can use with ORDER BY. (Sorting is done in ascending order by default.)
它是一个可选关键字,您可以与ORDER BY. (默认情况下按升序进行排序。)
回答by Klaus Byskov Pedersen
ORDER BY XXX DESCorders the results in descending order, as opposed to in ascending order ( ASC).
ORDER BY XXX DESC按降序排列结果,而不是按升序 ( ASC)。
回答by jay
DESCmeans descending.
DESC意味着下降。
if you have the letters A-Zin your database, and you sort them by ASC, it will go from Ato Z.
如果您有字母A-Z在您的数据库中,并且您按 对它们进行排序ASC,它将从A到Z。
ORDER BY DESCwill sort them from Zto A.
ORDER BY DESC将它们从Z到排序A。
same goes for 0-9, ascending and descending (for example).
同样适用于0- 9,升序和降序(例如)。
回答by Vimalnath
DESCmeans sorting the selected data in descending order.
Example Syntax:
DESC表示按降序对所选数据进行排序。示例语法:
SELECT `name` from users where `name` LIKE '%Emmett%' ORDER BY `name`;
This would yield/fetch names in Descending alphabetic order
这将按降序字母顺序产生/获取名称
回答by madhairsilence
DESC is the explicit word to mention the Order to make it descending. A simple Order by will do it Ascending
DESC 是提及顺序的明确词,以使其降序。一个简单的 Order by 将执行升序

