>hi there!
>
>it seems logical to me that using CASE...END in an ORDER BY clause ought
>to work.  i can set up a CASE statement in a SELECT:
>
>SELECT CASE test.ID WHERE 1 THEN 2 WHERE 2 THEN 1 END AS c
>
>and i get the expected output.  however, if i then try to move the whole
>case statement into the clause (ORDER BY CASE test.ID...END), then mysql
>seems to completely ignore the CASE...END instead;  i.e. the table is
>sorted as it would be without the CASE...END (if i do ORDER BY CASE
>test.ID...END, test.name - then it will simply be ordered by test.name).
>
>additionally, if i leave the SELECT CASE...END AS c and then try to
>ORDER BY c, mysql complains that column c is not known.
>
>any ideas on what i'm missing here?  this is using 3.23.32, compiled
>today.  it did the same thing with a .27-gamma release.
>
>thanks.

Sir, in the manual, the CASE structure is listed under the following heading:
    7.4 Functions for Use in SELECT and WHERE Clauses

Actually, I tried to look it up once before and couldn't find it, so 
I was sure that MySQL didn't support it. Your post prompted me to try 
looking it up again. I owe you some thanks for prompting me to 
correct my error.

Bob Hall

Know thyself? Absurd direction!
Bubbles bear no introspection.     -Khushhal Khan Khatak

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to