Reputation: 49
How do I merge the contents of two columns into one in SQLite? I'm not looking to union 2 columns, I just want SQLite to automatically copy the entire contents of two columns and dump them (in any order) into a single column. For example, suppose I have the following table:
Table1:
Column1: Column2:
Red, Yellow
Green, Red
Blue, Gold
Purple, Green
Black, White
And this is the desired result:
Red
Green
Blue
Purple
Black
Yellow
Red
Gold
Green
White
What's the simplest SQLite query that'll get to the desired result?
I tried the following: Select Column1 || Column2 FROM Table1;
But I got the undesired result:
RedYellow
GreenRed
BlueGold
PurpleGreen
BlackWhite
Upvotes: 0
Views: 82
Reputation:
I think that UNION ALL should give you the result:
Select Column1 AS Column_1_2 FROM Table1
UNION ALL
Select Column2 AS Column_1_2 FROM Table1;
Upvotes: 0