2016-03-03 71 views

回答

0
select max(case when id = 1 then col1 end) as `10`, 
      max(case when id = 2 then col1 end) as `20`, 
      max(case when id = 3 then col1 end) as `30`  
    from ((select id, `one`as col1, 1 as col2 from t1) union all 
      (select id, two, 2 as col2 from t1) union all 
      (select id, three, 3 as col2 from t1) union all 
      (select id, four, 4 as col2 from t1) union all 
      (select id, five, 5 as col2 from t1) 
     ) temp 
    group by col2;