如果你想要的是将所有分组的结果进一步合并成一个单独的、巨大的字符串(即整个查询结果只返回一个字符串),那么你需要借助子查询或者应用程序层面的逻辑。
在纯 SQL 中,这通常不是直接支持的功能,因为 SQL 是为返回结果集而设计的,而不是单一字符串。
SELECT GROUP_CONCAT(singleRes SEPARATOR '\n') AS lastRes
FROM (select CONCAT('field1:', yourTable.field1, ',',
'field2:', yourTable.field2, ',',
'field3:', yourTable.field3) as singleRes
from ic_sales_goods_inventory yourTable
where yourTable.create_time >= DATE_SUB(NOW(), interval 12 hour)
group by yourTable.field1, yourTable.field2, yourTable.field3
having count(1) > 1) AS grouped_orders;
SELECT GROUP_CONCAT(singleRes SEPARATOR '\n') AS lastRes
FROM (select CONCAT('field1:', yourTable.field1, ',',
'field2:', yourTable.field2, ',',
'field3:', yourTable.field3) as singleRes
from ic_sales_goods_inventory yourTable
where yourTable.create_time >= DATE_SUB(NOW(), interval 12 hour)
group by yourTable.field1, yourTable.field2, yourTable.field3
having count(1) > 1) AS grouped_orders;