0

Possible Duplicate:
MySQL query to sort upcoming birthdays based on current date

I have a MYSQL code like:

$friends=mysql_query("SELECT id,friend_id,f_name,
DATE_FORMAT(f_birthday,'%d %b')
AS f_birthday from friends where id='$id' 
ORDER BY MONTH(f_birthday), DAYOFMONTH(f_birthday)");

with this code block i can sort the user's birtdays with months and days starting from January first. But i can not sort them according to the upcoming birthdays. Searched for hours and found many solutions on stackoverflow but could not succeed. I really need help. Thanks.

EDIT

EXAMPLE OF MYSQL TABLE:

       id         friend_id        f_name      f_birthday
100001403795149 542542215       Mıchael        1984-10-01
100001403795149 557277949       MARY           1966-11-30
100001403795149 100002251590924 John           1985-07-05
100001403795149 100002534859304 Lucas          1977-09-15
4

1 回答 1

0
SELECT id,friend_id,f_name,
DATE_FORMAT(f_birthday,'%d %b')
AS f_birthday from friends where id='$id' and f_birthday >=now()
ORDER BY MONTH(f_birthday), DAYOFMONTH(f_birthday) asc
于 2012-10-16T14:50:17.607 回答