0

T1 is a table that contains all the values I want as a column name:

---------------
|      T1     |
---------------
|  id  |  v1  |
---------------
|  1   |  a   |
---------------
|  2   |  b   |
---------------
|  3   |  c   |
--------------- 

T2 is a table that contains all my data:

-------------------------------
|             T2              |
-------------------------------
|  id  |  art  |  t1v1  |  v1 |
-------------------------------
|  1   |   10  |   a    |  z  |
-------------------------------
|  2   |   10  |   c    |  y  |
-------------------------------  
|  3   |   11  |   a    |  x  |
-------------------------------
|  4   |   11  |   b    |  w  |
-------------------------------
|  5   |   11  |   c    |  v  |
-------------------------------

T3 is the view I want to create. The columns' name are the values from the column named v1 in T1:

---------------------------
|            T3           |
---------------------------
|  art  |  a  |  b  |  c  |
---------------------------
|   10  |  z  |     |  y  |
---------------------------
|   11  |  x  |  w  |  v  |
--------------------------- 

I tried a lot of solutions using GROUP_CONCAT in SELECT but I didn't find anything to create multiple columns based on line values. Is there a way to create that kind of views ?

Aleph0
  • 470
  • 2
  • 10
  • 27
  • Do you have more rows in table T1? And please update the question with query you have tried – Charvee Shah Jan 16 '15 at 09:30
  • @CharveeShah Yes it is just a small example and the real table contains a lot more values that could change in the future. – Aleph0 Jan 16 '15 at 09:32

0 Answers0