方法一:

思路:把原字符串的长度减去,把','变成空串后的字符串长度

代码:

select
    id,length(string) - length(replace(string,",","")) cnt
from strings