PHP MYSQL QUERY ORDER BY desc 问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4641608/
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
PHP MYSQL QUERY ORDER BY desc problem
提问by cj333
I have two field name $dateand $time.
我有两个字段名称$date和$time.
date | time
2011/01/09 | 08:22:25
2011/01/09 | 13:00:55
2011/01/09 | 17:45:18
2011/01/09 | 17:30:26
2011/01/08 | 18:22:00
2011/01/08 | 12:06:39
How to let the newest before the oldest. I want them to be:
如何让最新的在最旧的之前。我希望他们是:
date | time
2011/01/09 | 17:45:18
2011/01/09 | 17:30:26
2011/01/09 | 13:00:55
2011/01/09 | 08:22:25
2011/01/08 | 18:22:00
2011/01/08 | 12:06:39
How to write a select * from article order by...desc...? Thanks.
怎么写select * from article order by...desc...?谢谢。
回答by DRapp
SELECT * FROM yourtable ORDER BY date desc, time desc
回答by Michael Pakhantsov
select * from article order by date desc, time desc
回答by xrstf
SELECT * FROM article WHERE 1 ORDER BY `date` DESC, `time` DESC;
should do just fine.
应该没问题。
回答by sooraj subramanyan
$sql="SELECT * FROM CAFTERIA ORDER BY sl_no DESC;"
回答by Andy Hall
After reading the answer to this question and a bit of pain I discovered the following worked for me. This answer includes a PHP example for SELECT, WHERE, ORDER BYand LIMIT. They need to be in that ORDERwith LIMITlast of it doesn't work.
在阅读了这个问题的答案并有点痛苦后,我发现以下内容对我有用。这个答案包括了PHP例如SELECT,WHERE,ORDER BY和LIMIT。他们需要在ORDER与LIMIT过去的这是行不通的。
$query = "SELECT * FROM Page_Relations WHERE Child=$article_id ORDER BY Page_ID ASC LIMIT 0 , 30 ";
I wanted to create a context sensitive menu list where the pages in the index are ordered by a Page_IDnumber.
我想创建一个上下文相关的菜单列表,其中索引中的页面按Page_ID数字排序。

