[英]mysql - GROUP_CONCAT rows into a string
I have a following result set: 我有以下结果集:
req_id | p_id | ai_result | hash | sku
1 | 4 | Match | XAN | HOW
1 | 4 | Match | HXN | HOW
1 | 4 | Non Match | 123 | HOW
I need to have the following output 我需要以下输出
sku | matched | non_matched
HOW | XAN, HXN | 123
Here's as far as I could get: 这是我所能得到的:
SELECT sku, GROUP_CONCAT(hash) AS hash
FROM `sku_match`
GROUP BY req_id, p_id
How can I distinguish rows based on ai_result
column and put them separately. 如何基于
ai_result
列区ai_result
并将它们分开放置。 Something like GROUP_CONCAT(hash) AS matched, GROUP_CONCAT(hash) AS non_matched
? 像
GROUP_CONCAT(hash) AS matched, GROUP_CONCAT(hash) AS non_matched
?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.