[thelist] MySQL question

Joshua Olson joshua at waetech.com
Mon Apr 18 13:08:21 CDT 2005


> -----Original Message-----
> From: Erik Heerlein
> Sent: Monday, April 18, 2005 1:41 PM
> 
> I have two tables each with a column called 'email'. I would like to 
> gather up all of the distinct emails from both tables, no duplicates.
> 
> I have tried:
> 
> SELECT DISTINCT table1.email, table2.email
> FROM table1, table2
> 
> but that just gives me two separate columns. I know I've done this 
> before but I can't remember how to do it. Thank you for your time.

Erik,

You'll want to use the UNION command.  UNION automatically removes
duplicates between the two sets.

SELECT DISTINCT email
FROM table1
UNION
SELECT DISTINCT email
FROM table2

<><><><><><><><><><>
Joshua Olson
Web Application Engineer
WAE Tech Inc.
http://www.waetech.com/service_areas/
706.210.0168 





More information about the thelist mailing list