mysql convert column into row -
i have view created form multiple tables view structure is
id col1 col2 col3 col4 101 b b null 102 c f g and on (this sample)
i want create view like
id col_name value 101 col1 101 col2 b 101 col3 b 101 col4 null 102 col1 c 102 col2 f 102 col3 102 col4 g and on
can 1 plzzz
maybe this:
select id,'col1' colname, col1 value table1 union select id,'col2' colname, col2 value table1 union select id,'col3' colname, col3 value table1 union select id,'col4' colname, col4 value table1
Comments
Post a Comment