利用help_topic表把字元串轉換成行(分隔符號',') 統計字元串每個子串出現次數(分隔符號',') ...
利用help_topic表把字元串轉換成行(分隔符號',')
SELECT substring_index(substring_index('a,b,c,d,e,f,g,h',',',`help_topic_id`+1),',',-1) as `id` FROM mysql.`help_topic`;
統計字元串每個子串出現次數(分隔符號',')
SELECT substring_index(substring_index(A.`column`,',',B.`help_topic_id` + 1),',',-1) AS `sub_column`,COUNT(A.`column`) AS `count` FROM `test` A JOIN mysql.`help_topic` B ON B.`help_topic_id` < (length(A.`column`) - length(replace(A.`column`,',',''))+1) GROUP BY substring_index(substring_index(A.`column`,',',B.`help_topic_id` + 1),',',-1);