Bug #1207 | substr_count | ||
---|---|---|---|
Submitted: | 5 Sep 2003 17:02 | Modified: | 9 Sep 2011 7:40 |
Reporter: | Sorin Neacsu | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: DML | Severity: | S4 (Feature request) |
Version: | OS: | Any | |
Assigned to: | CPU Architecture: | Any |
[5 Sep 2003 17:02]
Sorin Neacsu
[26 Nov 2005 11:38]
Valeriy Kravchuk
Thank you for a feature request. Please, read the manual (http://dev.mysql.com/doc/refman/5.0/en/string-functions.html). I think, LOCATE function already implelemented allows to do what you asked for.
[12 Feb 2009 11:01]
PANEL Martin
LOCATE() can not count string repetition and no other function can it.
[9 Sep 2011 7:34]
Sergei Kulakov
I'd like to add my voice for the function. I too need a function to count the number of substring occurrences in a string, like PHP's substr_count(), it would really be handy. Right now we can achieve the same functionality by using the Replace() function: Cast((Length(Str)-Length(Replace(Str, Substr, '')))/Length(Substr) as Unsigned) But this is a bit cumbersome, as you can see. It would also be convenient to have a native implementation of substr_count() that would be case-insensitive (right now, of course, case insensitivity can also be achieved by using Lower() with Replace() but this will make the expression still more cumbersome).
[9 Sep 2011 7:40]
Valeriy Kravchuk
OK, although different workarounds are possible, this feature can still be useful.