SQL_245
查找字符串中逗号出现的次数
https://www.nowcoder.com/practice/e3870bd5d6744109a902db43c105bd50
方法一:
思路:把原字符串的长度减去,把','变成空串后的字符串长度
代码:
select id,length(string) - length(replace(string,",","")) cnt from strings
查找字符串中逗号出现的次数
https://www.nowcoder.com/practice/e3870bd5d6744109a902db43c105bd50
方法一:
思路:把原字符串的长度减去,把','变成空串后的字符串长度
代码:
select id,length(string) - length(replace(string,",","")) cnt from strings
相关推荐