测试数据表
以product_id;分组,把name字段的值打印在一行,逗号分隔(默认)
SELECT id,GROUP_CONCAT(name) FROM test_brand GROUP BY product_id;
以id分组,把name字段的值打印在一行,分号分隔
SELECT id,GROUP_CONCAT(name SEPARATOR ‘;‘) FROM `test_brand` GROUP BY product_id;
时间: 2024-10-24 06:32:30
测试数据表
以product_id;分组,把name字段的值打印在一行,逗号分隔(默认)
SELECT id,GROUP_CONCAT(name) FROM test_brand GROUP BY product_id;
以id分组,把name字段的值打印在一行,分号分隔
SELECT id,GROUP_CONCAT(name SEPARATOR ‘;‘) FROM `test_brand` GROUP BY product_id;