我有一张这样的表:
Product_ID | Size_ID
3 | S
3 | M
4 | L
5 | S
我希望结果如下:
Product_ID | Size_ID
3 | M, S
4 | L
5 | S
有可能吗?我的疑问是:
Select Product_ID, Size_ID
FROM product
Group by Product_ID
Order by Product_ID Desc
答案 0 :(得分:1)
尝试group_concat:
Select Product_ID, GROUP_CONCAT(Size_ID)
FROM product
Group by Product_ID
Order by Product_ID
答案 1 :(得分:1)
group_concat
函数可以解决这个问题:
Select Product_ID, GROUP_CONCAT(Size_ID ORDER BY Size_ID)
FROM product
Group by Product_ID
Order by Product_ID Desc