如何统计mysql字段中有多少个分号?
如何统计mysql字段中有多少个分号?
lz 图画的不错,用啥截图软件啊?学学。
下面是计算个数的,对于你截图的例子,你要加个 1 就可以了:
-
SQL code
mysql> select @str, length(@str) - length(replace(@str, ";", "")) as 'num'; +--------+------+ | @str | num | +--------+------+ | a;b;c;d| 3 | +--------+------+ 1 row in set
select length(f1)-length(replace(f1,';','')) from tt
select @str, length(@str) - length(replace(@str, ";", ""))