Suppose I have the following table with a single column:
Table_1
-----------
| nameCol |
-----------
| A |
| A |
| B |
| C |
-----------
And I want to create a new table with the following column names:
Table_2
| pk | A | B | C |
That is, the data from one table become the column names of the second table. There may be a pivot involved at some level, but I'm unable to really get the answer.
I tried:
create table Table_2 (
select group_concat(distinct(nameCol), " varchar(50), ")
from Table_1
);