Как запросить и спроектировать таблицы из верхней в нижнюю? большое спасибо - PullRequest
0 голосов
/ 05 марта 2020

Верхняя таблица на картинке - это моя текущая таблица, и я собираюсь изменить ее на нижнюю

Upper table on the picture is my current table and I intend to change it to the lower one

1 Ответ

0 голосов
/ 05 марта 2020

В 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
...