/*将逗号替换成空白,string长度减去新字段长度,就是逗号个数。 */ select id, length(string)-length(replace(string,',','')) as cnt from strings