Score
0
Watch 44 Star 256 Fork 69

xuthus / 数据库SQL实战SQLMIT

Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
Clone or download
51.查找字符串.md 355 Bytes
Copy Edit Web IDE Raw Blame History
xuthus authored 2019-08-12 23:23 . add:all

查找字符串'10,A,B' 中逗号','出现的次数cnt

题目描述

查找字符串'10,A,B' 中逗号','出现的次数cnt。

答案

select length('10,A,B') - length(replace('10,A,B',',','')) cnt

题解

利用字符串替换函数,将子串替换为空。(源串长度-替换后的串长度)/子串长度=子串出现次数

Comment ( 0 )

Sign in for post a comment