MENU

Excel / MySQL查询某个字符串出现次数

March 21, 2020 • 技术笔记

水一篇水一篇

Excel

=LEN(A1)-LEN(SUBSTITUTE(A1,要查找的字符串,""))

MySQL

SELECT LENGTH(字段名) - LENGTH(REPLACE(字段名,'要查找的字符串','')) AS num FROM 表名

没有思路,全靠百度...
原理很简单,就是将 要查找的字符串 替换为空,然后将原始字符串长度减去替换后的字符串长度,就得了-w-

Last Modified: April 13, 2020
Archives QR Code
QR Code for this page
Tipping QR Code