Only way I can think of is to use a temp table:

CREATE TEMPORARY TABLE test (fruits varchar(100) not null) TYPE=HEAP;
INSERT INTO test SELECT DISTINCT fruits1 FROM table;
INSERT INTO test SELECT DISTINCT fruits2 FROM table;
SELECT DISTINCT fruits FROM test;
DROP TABLE test;

However this can be slow, so perhaps you should restructure your table.

>    I have two columns in a table I need to get distinct values out of.  I
> know I can get distinct combinations of the values of the two
> columns with
> "SELECT DISTINCT fruits1, fruits2" but what I need is unique values among
> the two.  So that if in fruits1 I have values "apples" and "oranges", and
> in fruits2 I have values "bananas" and "oranges", my query will return
> values "apples", "oranges", "bananas".
>
>    Any ideas how this can be done?


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