MySQL: Get unique values across multiple columns in alphabetical order
- by RuCh
Hey everyone,
If my table looks like this:
id | colA | colB | colC
===========================
1 | red | blue | yellow
2 | orange | red | red
3 | orange | blue | cyan
What SELECT query do I run such that the results returned are:
blue, cyan, orange, red, yellow
Basically, I want to extract a collective list of distinct values across multiple columns and return them in alphabetical order.
I am not concerned with performance optimization, because the results are being parsed to an XML file that will serve as a cache (database is hardly updated). So even a dirty solution would be fine.
Thanks for any help!