I cannot figure out how to merge 4 different columns from 2 different tables together into just one single column of all possible results, with duplicates removed. The actual names are different, but suppose I have the following two tables
Table1
- Field1
- Field2
- SomethingElse
Table2
- Field1
- Field2
- SomethingElse
Now in the end, I would like to merge all 4 of these fields together into one large field, and then use distinct on top of that to eliminate any duplicates, as there are many of them. The final result should be just one single column containing every possible value found in all 4 columns, without any duplicated.
When I was working with just one single table with two fields, I had it working fine:
select distinct(Field1) from Table1 where SomethingElse = SomeVal
union
(select distinct(Field2) from Table1 where SomethingElse = SomeVal)
order by 1
(of course I wished to have run distinct
around the final result rather than each field)
Now I needed to add 2 more fields from another table. Nothing I have tried has even run, can't get the syntax right.