Table 1:
id | typeid | available|
0 | 1 | 12 |
0 | 2 | 44 |
Table 2:
typeid | typename |
1 | CL |
2 | ML |
I have a query using concatand group_concat:
select id,concat(group_concat(typename,available)) as types from table1
join table2 on table2.typeid=table1.typeid
I got the result as:
id | types |
0 | CL12,ML44 |
But I want to show it as follows:
id | CL | ML |
0 | 12 | 44 |
Is it possible to split the result group_concatinto column headings ?
I want to dynamically retrieve data from table2. Some users may add data to table2. So hard coding of the name is impossible.
source
share