List:General Discussion« Previous MessageNext Message »
From:Tim McDaniel Date:April 8 2008 4:11pm
Subject:Re: Help with ORDER BY using two colomns
View as plain text  
On Tue, 8 Apr 2008, Richard <mysql_list@stripped> wrote:
> Kristian Myllym>> mysql version?
>>
>> http://dev.mysql.com/doc/refman/5.0/en/case-statement.html
>>
>> order by case when updated is not null then updated else created
>> end desc;
>
> Hello I've tried the following with mysql 4.1.11
>
> SELECT * FROM quick_contact WHERE (`status` = '0') OR (`status` =
> '2' AND `update` < '".(time()-864000)."') CASE WHEN `update` = ''
> THEN ORDER BY `date` DESC ELSE ORDER BY `update` DESC END CASE;
>
> It does not work but, is it my code that is wrong or is it just that case
> does not work with mysql 4.1.11 ?

If you go to that URL, it's a section of the manual for MySQL 5.0.
However, a feature of their on-line manuals, incredibly clever and
useful for those of us with older or multiple versions, is near the
upper left:

     * MySQL 6.0 Reference Manual
     * MySQL 5.1 Reference Manual
     * MySQL 5.0 Reference Manual
     * MySQL 3.23/4.0/4.1 Manual

What's so incredibly clever and useful is that it takes you to *the
corresponding section of that version's manual*, if it exists.
However, in this case the "MySQL 3.23/4.0/4.1 Manual" link points to
the 5.0 page, which is, I think, how it indicates that a feature was
not in a previous version.

And, indeed, a bit of Googling says "MySQL 5.0 finally introduces
functionality for Stored Procedures. "

HOWEVER.  Kristian MyllymCASE *statement in stored procedures*.  As it says near the bottom,

     The syntax of the CASE *statement* used inside stored routines
     differs slightly from that of the SQL CASE *expression* described
     in Section 11.3, "Control Flow Functions".

The CASE expression is what you can use in a WHERE, et cetera.
The last bit is a link.  If you follow it, to
<http://dev.mysql.com/doc/refman/5.0/en/control-flow-functions.html>,
it describes the CASE expression for 5.0, and the link at the top
points to the slightly different 4.1 version,
<http://dev.mysql.com/doc/refman/4.1/en/control-flow-functions.html>

-- 
Tim McDaniel, tmcd@stripped
Thread
Help with ORDER BY using two colomnsRichard8 Apr
  • Re: Help with ORDER BY using two colomnsKristian Myllymäki8 Apr
    • Re: Help with ORDER BY using two colomnsRichard8 Apr
      • Re: Help with ORDER BY using two colomnsRafael Barbolo Lopes8 Apr
        • Re: Help with ORDER BY using two colomnsRichard8 Apr
          • Re: Help with ORDER BY using two colomnsBen Clewett8 Apr
            • Re: Help with ORDER BY using two colomns [ solved thankyou :) ]Richard8 Apr
              • Re: Help with ORDER BY using two colomns [ solved thankyou :) ]Ben Clewett8 Apr
                • Re: Help with ORDER BY using two colomns [ solved thankyou :) ]Richard8 Apr
                  • Re: Help with ORDER BY using two colomns [ solved thankyou :) ]Andy Wallace8 Apr
                    • Re: Help with ORDER BY using two colomns [ solved thankyou :) ]Richard8 Apr
                  • Re: Help with ORDER BY using two colomns [ solved thankyou :) ]Ben Clewett8 Apr
      • Re: Help with ORDER BY using two colomnsTim McDaniel8 Apr
  • Re: Help with ORDER BY using two colomnsBen Clewett8 Apr