I believe a sub-select with the DISTINCT command would do it.
You would have to look up the syntax.

Also, it seems that some people seem to be having a problem with sub-selects but
I don't have any direct experience to convey.


At 01:12 PM 1/23/03 -0600, Doug Coning wrote:
Is this possible in MySQL without using a temporary table with multiple SQL
commands:

I am trying to SELECT the results of multiple columns into 1 column or
Alias,
group them and sort them.

So if I had a table with 4 fields: Cat1, Cat2, Cat3, & Cat4 like such:

+-----+------+-----+------+
| Cat1| Cat2 | Cat3| Cat4 |
+-----+------+-----+------+
|  F     |   A   |         |   A   |
|  D     |   C   |   H   |   A   |
|  G     |         |         |         |
|  F      |   B   |   I     |   A   |
+-----+------+-----+------+

It would select all the values, merge them into 1 column, group them, and
sort them like such so that the result would be a single column, returning
only 1 instance of each returned value:

+--------+
| Result |
+--------+
|     A     |
|     B     |
|     C     |
|     D     |
|     F     |
|     G     |
|     H     |
|      I     |
+--------+

Is there as singe Select command that can do this?  Right now I am using a
temporary table where I first clear out the values, then copy each column
one at a time over into the tables...  It works, however, I was wondering if
there is an easier way to get the single column result with all the merged
information without having to use a temporary table...

Thanks,

Doug Coning





---------------------------------------------------------------------
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


---------------------------------------------------------------------
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