MySQL Pivot Table

前端 未结 1 548
半阙折子戏
半阙折子戏 2021-01-20 12:12

Over the past few days, I have been trying to find an answer to this problem. While I have not found an answer, this site keep appearing in my search results so I thought I

相关标签:
1条回答
  • 2021-01-20 12:40

    You could try (untested) something like

    select form_id, 
    max(case data_label when 'lastName' then data_value else null end) as lastname, 
    max(case data_label when 'firstName' then data_value else null end) as firstname,
    max(case data_label when 'phone' then data_value else null end) as phone
    from mytable 
    group by form_id
    
    0 讨论(0)
提交回复
热议问题