获取每行字符串字段逗号个数
(题目)[https://www.nowcoder.com/share/jump/4394623561720098946857]
drop table if exists strings;
CREATE TABLE strings(
id int(5) NOT NULL PRIMARY KEY,
string varchar(45) NOT NULL
);
insert into strings values
(1, '10,A,B'),
(2, 'A,B,C,D'),
(3, 'A,11,B,C,D,E');
将所有逗号去掉,原始长度-修正后的长度。
select id,length(string)-length(replace(string,",","")) from strings;

等我先恰个🍎

浙公网安备 33010602011771号