str=5452,5453,5454,5458,5466,5480,5492,5503,5507,5510,5783,183,530,583,648,921,1082,1116,1159,1194,1415,1526,1546,1599,1910,2154,2203,2367,2371,2377,2496,2661,2817,2851,2896,2923,3096,3191,3196,3267,3352,3499,3596,3602 mysql 统计多少个逗号
SET @str = '5452,5453,5454,5458,5466,5480,5492,5503,5507,5510,5783,183,530,583,648,921,1082,1116,1159,1194,1415,1526,1546,1599,1910,2154,2203,2367,2371,2377,2496,2661,2817,2851,2896,2923,3096,3191,3196,3267,3352,3499,3596,3602';
SELECT
(LENGTH(@str) - LENGTH(REPLACE(@str, ',', ''))) AS comma_count;
这个查询语句首先使用SET语句定义了一个变量@str,并将你提供的字符串赋值给它。然后,它使用LENGTH()函数计算原始字符串的长度,并使用REPLACE()函数将字符串中的所有逗号替换为空字符串。接着,它再次使用LENGTH()函数计算替换后字符串的长度。最后,它通过计算两个长度的差值来得到逗号的数量,并将结果命名为comma_count。
执行这个查询语句后,你将得到一个结果集,其中包含逗号的数量。