我有三张桌子如下
manufacturing_detail_history有两列主键,描述
manufacturing_products_history有两列主键和manu_product_id (主键是manufacturing_detail_history主键引用)
manufacturing_products有三列( manu_product_id、name、type )
需要在manu_product_names中添加一个新列manufacturing_detail_history,并使用逗号分隔的值填充制造产品名称。
不确定如何为每个manu_product_name获取关联的多个manu_product_id,并使其为逗号分隔的值并插入到manu_product_names列中
提前谢谢。
发布于 2016-02-20 06:07:24
Select
T1.ID, T1.Desc,
T2.manu_product_id,
GROUP_CONCAT(T3.name ORDER BY T3.name ASC SEPARATOR ',')
From
manufacturing_detail_history AS T1
inner join
manufacturing_products_history AS T2 ON T1.ID = T2.ID
inner join
manufacturing_products AS T3 ON T3.manu_product_id = T2.manu_product_id
GROUP BY T1.ID, T1.Desc, T2.manu_product_id;https://stackoverflow.com/questions/35484928
复制相似问题