Answer Question
MySQL ORDER BY dictionary query.
Is it possible in SQL to sort a result according to a user defined 'dictionary'?
I don't know whether this is possible - or perhaps there is a workaround - but to explain what I would like to do:
Consider this example:
SELECT * FROM text ORDER BY language
The query selects all rows from the text table and orders them by their language field. The language field could be "english", "spanish", "german" etc.
This will result in rows being grouped together by language, but which one comes first will be quite arbitrary - in this case it would be English, since it's alphabetically the first.
I want to be able to alter the order on a per query basis, ie. specify that for this query, "spanish" = 0, "english" = 1, "german" = 2, so that Spanish texts comes first, followed by English and German.
In the next query I might want to change this to something else.
This is the same as saying that in my "dictionary",
Spanish comes before
English which comes before
German
I know I can do it by multiple select statements (one for each language), but wonders if there is a quick way to do it in just one select (or any fixed number of selects, regardsless of the number of of languages).
Come on guys and girls, give it your best shot!
Jakob
TEXT
Uploading file and scanning for virus...
Please Wait