0

我想在我的网站上显示未来即将到来的生日,因此使用出生日期(dateofb)对它们进行排序,以下查询未按 dateofb 顺序显示 bateof 出生。它使用id按顺序显示。

" dateofb 包含 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']); } ?>
4

2 回答 2

0

你可以做这样的事情......

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
于 2012-09-03T20:26:27.667 回答
0

使用默认排序,它将如下所示:

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.
于 2012-09-03T21:11:27.553 回答