I have one table which contains multiple param name and param value.
I would like to select the records in such a way that all param name should come as header/column name and param values should get as multiple rows.
How to do it in mysql ?
I have one table which contains multiple param name and param value.
I would like to select the records in such a way that all param name should come as header/column name and param values should get as multiple rows.
How to do it in mysql ?
use case when expression
select max(case when param_name='school' then param_value end) as school,
max(case when param_name='bus' then param_value end) as bus
from tablename group by test2_id
fa06's answer is probably the best way to make this type of selection if there is a known, static set of param_name values, for which case you can just hardcode them in. If not, you'd probably want to first select unique param_name entries and then a selection of the param_values for each different param_name.