|
Posted by Serge Rielau on 07/28/06 16:33
deane.barker@gmail.com wrote:
> Thanks.
>
> FYI -- I've learned in the meantime that MySQL has this functionality:
>
> ORDER BY FIELD(my_field, 'value2','value1','value3')
>
> Syntactic sugar, to be sure, but still handy.
The densest way to write it in ANSI SQL is this:
SELECT my_field FROM my_table JOIN (VALUES(1, 'value2'),
(2, 'value1'),
(3, 'value3')) AS V(I, val)
ON myfield = val
ORDER BY i
This way you don't need to repeat the values.
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
IOD Conference
http://www.ibm.com/software/data/ondemandbusiness/conf2006/
[Back to original message]
|