Because doing calculations directly on the database is often fasterLet's say our column in named 'col' and table is named 't2'.
Count occurrences of specified character within a string
Will count number of occurrences of character '.' in column 'col'SELECT LENGTH( REPLACE(col, '.', '@@') ) - LENGTH( col ) FROM t2
Count occurrences of specified substring within a string
Will count number of occurrences of substring 'ab' in column 'col'SELECT ROUND(( LENGTH( REPLACE(col, 'ab', REPEAT('ab', 2)) ) - LENGTH( col ) ) / 2) FROM t2