目前,每行都会显示按行分组的列。我想只在分组更改时显示列。
例如:
water sea
ocean
river
sand beach
desert
trees woods
forest
答案 0 :(得分:0)
如果您必须在MySQL中执行此操作,则可以执行以下操作:
select your_column1, group_concat(distinct your_column2 separator '\n') from your_table
group by your_column1;
这
your_column1 | your_column2
----------------------------
water | sea
----------------------------
water | ocean
----------------------------
water | river
----------------------------
sand | beach
----------------------------
sand | desert
----------------------------
trees | woods
----------------------------
trees | forest
要
your_column1 | your_column2
----------------------------
water | sea
| ocean
| river
----------------------------
sand | beach
| desert
----------------------------
trees | woods
| forest