List:General Discussion« Previous MessageNext Message »
From:Paul Date:October 4 2004 9:06am
Subject:Re: MySQL Order by 2 date fields
View as plain text  
On Mon, 4 Oct 2004 11:03:13 +0200, Martijn Tonies <m.tonies@stripped> wrote:
> Hello,
> 
> > I have two date fields (1095689105) in mysql. One is Creation date and
> > other is Modify date. If news is not modified its value is 0. How can I
> > sort my news so modify date is more important (if exists) than creation
> > date?
> 
> What about an ORDER BY with a CASE statement that uses
> the CreationDate if ModifyDate = 0 and ModifyDate if it's <> 0.
> 
> With regards,

Or use:

ORDER BY if(ModifyDate = 0,1, ModifyDate), CreationDate

Paul
Thread
MySQL Order by 2 date fieldsKhan4 Oct
  • Re: MySQL Order by 2 date fieldsMartijn Tonies4 Oct
    • Re: MySQL Order by 2 date fieldsPaul4 Oct
      • Re: MySQL Order by 2 date fieldsEldo Skaria4 Oct
        • Re: MySQL Order by 2 date fieldsSGreen4 Oct