如何从上表到下表进行查询和设计?

How to query and design tables from upper one into lower one?

图上的table是我现在的table,打算换成下面的

在 MySQL 中,您可以使用 union all 取消透视:

(select id, category, 1990 year, `1990` data from mytable where `1990` is not null)
union all
(select id, category, 1991, `1991` from mytable where `1991` is not null)
union all
(select id, category, 1992, `1992` from mytable where `1992` is not null)
union all
(...)
order by id, category, year