我正在尝试将功能和价值全部集中在一行上。有人推荐了 GROUP_CONCAT,但是当我这样做时,我失去了所有其他产品。这是我目前的 SQL 调用
SELECT ps_product_lang.name, CONCAT(ps_feature_lang.name) AS feature, ps_feature_value_lang.value FROM ps_product LEFT JOIN ps_product_lang ON ps_product_lang.id_product = ps_product.id_product LEFT JOIN ps_feature_product ON ps_feature_product.id_product = ps_product.id_product LEFT JOIN ps_feature_lang ON ps_feature_lang.id_feature = ps_feature_product.id_feature LEFT JOIN ps_feature_value_lang ON ps_feature_value_lang.id_feature_value = ps_feature_product.id_feature_value
这给了我这样的回报
name feature value
MRO Plus Heavy Pad Height 5
MRO Plus Heavy Pad Width 12
MRO Plus Heavy Pad Depth 13
MRO Plus Heavy Pad Weight 15
ENV810™ Sorbent Boom Height 88
ENV810™ Sorbent Booms Width 50
ENV810™ Sorbent Booms Depth 23
ENV810™ Sorbent Booms Weight 45
ENV510™ Sorbent Booms NULL NULL
MRO Plus Medium Pad NULL NULL
当我尝试 GROUP_CONCAT 时,我的结果看起来像这样。
Name Feature Value
MRO Plus Heavy Pad Height,Width,Depth,Weight,Height,Width,Depth,Weigh... 5,12,13,15,88,50,23,45
MySQL中有没有办法让它看起来像这样
Name Feature Value
MRO Plus Heavy Pad Height, Width, Depth, Weight 5, 12, 13, 15
ENV810 Sorbent Boom Height, Width, Depth, Weight 88, 50, 23, 45
ENV510 Sorbent Boom Null Null
MRO Plus Medium pad Null Null
任何帮助将不胜感激!