How can I combine two tables using the row data of table 2 as column header?
table 1:
id | firstname | middlename | lastname | |
---|---|---|---|---|
2901 | john@io.com | john | michael | smith |
table 2:
id | questionId | answer |
---|---|---|
2901 | 1 | Toronto |
2901 | 2 | Canada |
2901 | 3 | 9991118721 |
Final result should be table 1 headers plus questionId data as header, then using table 1 data and table 2 answer data as rows:
id | firstname | middlename | lastname | 1 | 2 | 3 | |
---|---|---|---|---|---|---|---|
2901 | john@io.com | john | michael | smith | Toronto | Canada | 9991118721 |