Jump to content


Photo

Multiple order by


  • Please log in to reply
2 replies to this topic

#1 Canman2005

Canman2005
  • Members
  • PipPipPip
  • Advanced Member
  • 669 posts

Posted 29 March 2006 - 02:44 AM

Dear all

I have a sql statement with a ORDER BY at the end of it, I then have 3 fields in my database, the fields are

day (ie: 02)
month (ie: 11)
year (ie: 2004)

basically at the moment it orders by results by id number, but what I want to do is to order the results by day, month and year so it orders the results by newest to oldest using the day, month and year stamp.

Is this possible?

Thanks in advance

Ed

#2 toplay

toplay
  • Staff Alumni
  • Advanced Member
  • 973 posts

Posted 29 March 2006 - 03:13 AM

Try:
[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] * FROM table_name WHERE something ORDER BY `year` DESC, `month` DESC, `day` DESC [!--sql2--][/div][!--sql3--]


#3 Canman2005

Canman2005
  • Members
  • PipPipPip
  • Advanced Member
  • 669 posts

Posted 29 March 2006 - 03:32 AM

cool

thanks




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users