mysql所有列显示为一个字段

 SELECT
 products_id AS products_id,
 group_CONCAT(DISTINCT TT2.mydesc separator ' , ') AS desccrption
 FROM
(
 SELECT products_id,
 CONCAT_WS(SPACE(1),attribute.attribute_name,products_attribute.attribute_value) AS mydesc
 FROM products_attribute
 LEFT JOIN attribute
 ON attribute.attribute_id = products_attribute.attribute_id
) AS TT2

 

 

原数据:

products_id    mydesc

AL1001A       Color Black

AL1001A       HEAD Mono

AL10021A     Color Black

AL1002B        HEAD Mono

 

结果数据:

products_id desccrption

AL1001A      Color Black , HEAD Mono

AL10021A    Color Black

AL1002B      HEAD Mono

你可能感兴趣的:(JOIN,mysql)