MySQL;来自不同类别的列表

MySQL; List from different categories

假设我有以下 table 称为 test:

我需要 SELECT 才能获得以下内容:

有人知道如何用 SQL 做到这一点吗?

您可以使用 UNION ALL:

select category,
    item
from test
where category is not null

union all

select category2 as category,
    item
from test
where category2 is not null
order by item

Demo