pccode
09-26-2008, 11:36 AM
I need to retrieve all of the distinct entries from 2 columns in 2 different tables.
Table1
Column1 Column2
John Doe
James Smith
Bob Johnson
Table2
Column1 Column2
John Doe
James Smith
Jane Doe
In the example above I would need to retrieve all of the distinct entries from column1 in both Table1 and Table2. The results should be the following.
John, James, Bob, Jane
How can I achieve this with a single sql statement? I've tried the command below, but it doesn't combine the results from both tables and filter out the duplicates, it simply retrieves all of the distinct entries from each table.
SELECT DISTINCT Table1.Column1, Table2.Column1 FROM Table1, Table2
Table1
Column1 Column2
John Doe
James Smith
Bob Johnson
Table2
Column1 Column2
John Doe
James Smith
Jane Doe
In the example above I would need to retrieve all of the distinct entries from column1 in both Table1 and Table2. The results should be the following.
John, James, Bob, Jane
How can I achieve this with a single sql statement? I've tried the command below, but it doesn't combine the results from both tables and filter out the duplicates, it simply retrieves all of the distinct entries from each table.
SELECT DISTINCT Table1.Column1, Table2.Column1 FROM Table1, Table2