Not so easy SELECT statement (atleast not for me)

mpauley73
01-15-2004, 06:03 AM
Hi everyone...

I have a table with 3 fields,

ID Lead Helper
1 John Peter
2 Bob
3 Larry John


and I would like to get distinct names for Lead and Helper in one column. Is that possible?

Thanks in advance,

Pauley

davie
01-15-2004, 06:05 AM
SELECT DISTINCT Lead
FROM tbNames
UNION SELECT DISTINCT Helper
FROM tbNames

mpauley73
01-15-2004, 06:22 AM
davie,

Thanks for the quick response! Unfortunately Im only running mySQL 3.23 and UNION wasn't implemented until 4.x. Anyother suggestions, beside for upgrading :-)?

davie
01-15-2004, 06:23 AM
you could append them to a temporary table

mpauley73
01-15-2004, 07:04 AM
you could append them to a temporary table

And thats exactly what i just found...

For anyone else with this issue:

CREATE TEMPORARY TABLE temp_union
SELECT DISTINCT Lead from signs;
INSERT INTO temp_union
SELECT DISTINCT Comm from `signs`;
SELECT DISTINCT * FROM temp_union ORDER by Lead;

Thanks for your help!

Pauley

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum