比如拼接查询出来后的值是
然后想要查出customer_role 中,各个数字出现的次数是多少
select
obj.customer_role,count(*)as customerRoleNum,obj.customer_id
from (
SELECT substring_index(substring_index( a.customer_role, ',', b.help_topic_id + 1 ), ',',- 1 ) AS customer_role,a.customer_id
FROM(
SELECT GROUP_CONCAT( obj.customer_role)as customer_role,obj.customer_id
from b_customer_request obj
where obj.customer_id = '014864fde78747b' and obj.request_type = 1
) a
JOIN mysql.help_topic b ON b.help_topic_id < (length( a.customer_role ) - length( REPLACE ( a.customer_role, ',', '' ) ) + 1 )
) obj
group by obj.customer_role order by count(1) desc
-- limit 1 // 这里限制条数根据自己的需求来
查询结果如下: