MYSQL Query for converting row to column header dynamically -


+--------+----------+-----------+---------+ | hostid | itemname | itemvalue | quantity|     +--------+----------+-----------+---------+ |   1    |        |    10     | 1       | |   1    |    b     |     3     | 2       | |   2    |        |     9     | 3       | |   2    |    c     |    40     | 4       | +--------+----------+-----------+---------+ 

how query database return like:

+--------+-----------------+-----------------+-------------------+ | hostid |               |           b     |        c          | |        |-------+---------+-------+---------+--------+----------+         |        |itemval| quantity|itemval| quantity| itemval| quantity | +--------+-------+---------+-------+---------+--------+----------+  |   1    |  10   |  1      |   3   |     2   |   null |    null  | |   2    |   9   |  3      |   null|   null  |   40   |    4     | +--------+-------+---------+-------+---------+--------+----------+ 

can me this?


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -