I want to do something like this
SELECT ID, X, Y, Z FROM TABLE_1
this returns me something like:
| IDTABLE_1 | X | Y | Z |
| 1 | a | b | c |
| 2 | d | e | f |
| 3 | g | h | i |
And i have another table TABLE_2 that has a column with the column names from the previous table (TABLE_1):
| IDTABLE_2 | COLUMN |
| 101 | X |
| 102 | Y |
| 103 | Z |
and now i need to insert all my data from the select into this new table TABLE_3 and it has to be like this:
| IDTABLE_3 | IDTABLE_1 | IDTABLE_2 | VALUE |
| 201 | 1 | 101 | a |
| 202 | 1 | 102 | b |
| 203 | 1 | 103 | c |
| 204 | 2 | 101 | d |
| 205 | 2 | 102 | e |
| 206 | 2 | 103 | f |
| 207 | 3 | 101 | g |
| 208 | 3 | 102 | h |
| 209 | 3 | 103 | i |
Any suggestion on a simple way to do it?