Insert each column of one table as a row in another table
I have one table with the following columns:
c1, c2, c3, c4,开发者_JAVA技巧 c5
And another table with the following columns:
id, column_info
...there are some other columns but here's the main problem.
For each column in table 1, I'd like to insert a row in table 2, like this:
id | column_info
---|------------
1 | c1
2 | c2
3 | c3
4 | c4
5 | c5
Is this possible as an SQL statement?
INSERT INTO Some_Table (id, column_info)
SELECT id, c1 UNION ALL
SELECT id, c2 UNION ALL
SELECT id, c3 UNION ALL
SELECT id, c4 UNION ALL
SELECT id, c5
精彩评论