PHP MYSQL QUERY ORDER BY desc problem
I have two field name $date
and $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开发者_JS百科...desc...
? Thanks.
SELECT * FROM yourtable ORDER BY date desc, time desc
select * from article order by date desc, time desc
SELECT * FROM article WHERE 1 ORDER BY `date` DESC, `time` DESC;
should do just fine.
$sql="SELECT * FROM CAFTERIA ORDER BY sl_no DESC;"
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 BY
and LIMIT
. They need to be in that ORDER
with LIMIT
last of it doesn't work.
$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_ID
number.
精彩评论