Question : Query For Unique Values From the Same Table and Different Columns

Greetings;

I have a table containing 2 columns of similar information. In this case CodeA and CodeB because the row may have:

* neither a value in CodeA nor CodeB
* a value in CodeA only
* values in both CodeA and CodeB
* never a value only in CodeB

Example:

If codes exist with values of 1, 2, 3, 4, 5, 6 then:

* row 1 may contain the value 1 in CodeA column
* row 2 may contain no values in CodeA or CodeB
* row 3 contains the values 2 and 3 in CodeA and CodeB, respectively
* row 4 contains the values 1 and 2 in CodeA and CodeB, respectively.

The select query I'm looking for needs to result in a single column with distinct values used in CodeA and CodeB. In the example this select would return 1, 2, 3.

Much thanks ... David

Answer : Query For Unique Values From the Same Table and Different Columns

if you don't want to include the null values:

SELECT DISTINCT CodeA FROM urTable WHERE CodeA IS NOT NULL
UNION
SELECT DISTINCT CodeB FROM urTable WHERE CodeB IS NOT NULL
Random Solutions  
 
programming4us programming4us