Mysql, reshape data from long / tall to wide

前端 未结 3 762
Happy的楠姐
Happy的楠姐 2020-12-02 23:26

I have data in a mysql table in long / tall format (described below) and want to convert it to wide format. Can I do this using just sql?

Easiest to explain with an

3条回答
  •  有刺的猬
    2020-12-02 23:52

    If you were using SQL Server, this would be easy using UNPIVOT. As far as I am aware, this is not implemented in MySQL, so if you want to do this (and I'd advise against it) you'll probably have to generate the SQL dynamically, and that's messy.

提交回复
热议问题