This question already has answers here:
How to use GROUP BY to concatenate strings in MySQL?
(6个答案)
三年前关闭。
它的my query连接表:
SKU | Atributes | Atributes_Value
123 | Color     | Black
123 | Size      | 40

我可以这样修改select查询吗?(下)
SKU | new_atributes_value
123 | Black 40

我只想在一行中看到相同SKU的数据!我试过使用distinct,但没有得到理想的结果(如下)
SKU | Atributes | Atributes_Value
123 | Color     | Black

我的问题是40号在哪里?我想看看SKU123的商品是黑色的,一排40号。。有人能帮我吗?我需要我的电子商务网站的数据

最佳答案

试试这个。。。。。。。。。。

SELECT sku, group_concat(Atributes_Value separator ' ') as attr_val from table_name group by sku

10-05 20:29
查看更多