I have empty table below:
----------------
|id|c_id|c1|c2|c3|c4|
----------------
| | | | | | |
And another table:
|id|c_id|type|value|
--------------------
1 | 1 | c1 | 234 |
-------------------
2 | 1 | c2 | 211 |
-------------------
3 | 3 | c2 | 4 |
--------------------
5 | 4 | c3 | 54 |
--------------------
5 | 5 | c4 | 789 |
--------------------
6 | 2 | c1 | 234 |
I want to fill table1 with value from table2. As you can see column "type" will be devided into 4 columns in table 1. How I can do it with 1 query?
What i expect:
|id|c_id| c1 | c2 | c3 | c4 |
----------------------------------
|1 | 1 | 234 | 211 | null | null |
----------------------------------
|2 | 2 | 234 | null| null | null |
----------------------------------
|3 | 3 | null| 4 | null | null |
----------------------------------
|4 | 4 | null| null| 54 | null |
----------------------------------
|5 | 5 | null| null| null | 789 |