题解 | #查找字符串中逗号出现的次数#
select id, length(string) - length(replace(string, ',' , '')) cnt from strings;
注意点; 1、mysql中无需as。 2、巧妙运用字符串长度计算逗号。 **length(replace(**字符串,字符串需要替换的,将要替换成)).
select id, length(string) - length(replace(string, ',' , '')) cnt from strings;
注意点; 1、mysql中无需as。 2、巧妙运用字符串长度计算逗号。 **length(replace(**字符串,字符串需要替换的,将要替换成)).
相关推荐