Skip to content
Advertisement

Get column name of Table based on query

I have this SQL query

Query

And this is my table let’s say

Tree_table

So I want my output to be

Is this possible using SQL query or even PHP will do

Advertisement

Answer

You need to unpivot the data. In MySQL, this is probably most easily done with union all:

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement