|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
I have a Char(50) column and I want to count the number of "." in the
column using a Select statement. I don't see any MySQL function that can count the number of occurrences of a character in a string. Is there a simple way to do this? TIA Mike |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Hi,
On Dec 12, 2007 5:39 PM, mos <mos99@fastmail.fm> wrote: > I have a Char(50) column and I want to count the number of "." in the > column using a Select statement. I don't see any MySQL function that can > count the number of occurrences of a character in a string. Is there a > simple way to do this? LENGTH(str) - LENGTH(REPLACE(str, '.', '')) |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
At 04:52 PM 12/12/2007, Baron Schwartz wrote:
>Hi, > >On Dec 12, 2007 5:39 PM, mos <mos99@fastmail.fm> wrote: > > I have a Char(50) column and I want to count the number of "." in the > > column using a Select statement. I don't see any MySQL function that can > > count the number of occurrences of a character in a string. Is there a > > simple way to do this? > >LENGTH(str) - LENGTH(REPLACE(str, '.', '')) Baron, Thanks, I gave it a try and it works. ![]() But why can't MySQL create a function to do that otherwise the SQL harder is much harder to read. Just my 2 cents worth. Mike |
|
![]() |
| Outils de la discussion | |
|
|