我想在我的网站上显示未来的生日,所以使用出生日期(dateofb)订购下面的查询没有按出生日期的顺序显示出生日期。它使用id按顺序显示。
"b的日期包含1970年9月2日的出生日期。"
<?php $sel = $db->query("select * from mov_biography order by dateofb asc limit 0,5");
while($row=mysql_fetch_array($sel)){
echo ($row['name']); } ?>
你可以这样做。。。
SELECT
, MONTH(dateofb) AS month
, DAY(dateofb ) AS day
FROM <table_name>
WHERE birthday BETWEEN NOW() AND DATE_ADD(NOW, INTERVAL 90 DAY)
ORDER BY Birthday DESC
使用默认排序,它看起来如下所示:
mysql> SELECT column FROM table_name ORDER BY column;
column
======
100
1000
10000
200
2000
20000
...
Now with "... ORDER BY column+0", I get it sorted right:
mysql> SELECT column FROM table_name ORDER BY column+0;
column
======
100
200
1000
2000
10000
20000
...
This is a quick fix instead of sorting to CAST operator.