mysql中怎么统计某字段里某个字符的个数

CREATE function [dbo].[GetCharIndexNum](@findstring varchar(max),@string varchar(max))returns intASBEGIN declare @location int , --要找的字符位置 @num int --要找的字符出现的次数 set @num =0 set @location = charindex (@findstring,@string) while @location >0...
mysql中怎么统计某字段里某个字符的个数
CREATE function [dbo].[GetCharIndexNum](@findstring varchar(max),@string varchar(max))returns intASBEGIN declare @location int , --要找的字符位置 @num int --要找的字符出现的次数 set @num =0 set @location = charindex (@findstring,@string) while @location >0 ---字符串中存在要找的字符 begin set @num =@num +1 set @string =substring(@string,@location+1,len(@string)) set @location = charindex (@findstring,@string) endreturn @numEND--举个例子调用这个标量值函数 select [dbo].[GetCharIndexNum]('5','abc5ab5')
返回值2,5这个字符出现了2次
2017-01-19
mysql中怎么统计某字段里某个字符的个数
select 字段名, count(*) from 表 group by 字段名2017-01-18
统计指定表中,用逗号分隔的字符串个数,如果只要统计逗号的个数把+1去掉;
select *,ROUND((LENGTH(`字段名`) - LENGTH(REPLACE (`字段名`, ",", ""))) / LENGTH(","))+1 as num 表名 WHERE `字段名`<>'';2022-04-13
select char_length(某字段) from tbl2017-01-18
mengvlog 阅读 82 次 更新于 2025-12-17 10:39:45 我来答关注问题0
檬味博客在线解答立即免费咨询

mySQL相关话题

Copyright © 2023 WWW.MENGVLOG.COM - 檬味博客
返回顶部