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

用总的字符长度减去删除掉','符号的字符总长度得到的就是其中','符号的数量。