MySQL如何把多行合并为一行?

MySQL如何把多行合并为一行?
最关键的是要使用 GROUP_CONCAT group

示范SQL语句:

select
ordered_item.id as `Id`,
ordered_item.Item_Name as `ItemName`,
GROUP_CONCAT(Ordered_Options.Value) as `Options`
from
ordered_item,
ordered_options
where
ordered_item.id=ordered_options.ordered_item_id
group by
ordered_item.id

发表回复

您的电子邮箱地址不会被公开。