sql - MySQL table with key/value pairs, get keys as column names -


i have mysql database can following query:

mysql> select name, value info id = 110506;  +-------+-----------+ | name  | value     | +-------+-----------+ | start | 228196    | | stop  | 228318    | | fwd   | 0         |  +-------+-----------+ 3 rows in set (0.00 sec) 

i trying construct query result be

+--------+--------+-----+ | start  | stop   | fwd | +--------+--------+-----+ | 228196 | 228318 | 0   | +------- +--------+-----+ 1 row in set (0.00 sec) 

i not know in advance names in name column be, need somehow dynamically set them result of selectquery. how do that?

try this

select     max(case when name = 'start' value end) `start`,     max(case when name = 'stop' value end) `stop`,     max(case when name = 'fwd' value end) `fwd` info id = 110506; 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -