On Tue, 8 Apr 2008, Richard <[EMAIL PROTECTED]> wrote:
Kristian Myllym?ki a ?crit :
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 Myllym?ki gave the wrong URL.  That was for the
CASE *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, [EMAIL PROTECTED]
-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to