string长度减去 将逗号替换为空字符串的长度 即是 逗号数量

select id, LENGTH(string) - LENGTH(replace(string, ',','')) cnt
    from strings;