1

I have two columns in my DB with team names in each column. But, sometimes a team could be in one column, and sometimes it can be in the other column. I want to create a list of distinct, unique, names from both columns combined.

Maybe for further explanation, what I'm trying to say is combine the two columns and then run a distinct query on the combined data to get only unique names out. Thanks!

1 Answer 1

2

Use union to get a distinct list

select team1 as team from your_table
union 
select team2 from your_table
Sign up to request clarification or add additional context in comments.

2 Comments

So will the result set have only unique team names? Or does this just return a list of the two combined teams and then I have to run a DISTINCT query?
union all would return the total list, but just union reduces it to the distinct values

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.