I have a table like this:
TITLE | DESCRIPTION ------------------------------------------------ test1 | value blah blah value test2
Here is a function that will do that.
CREATE FUNCTION count_str(haystack TEXT, needle VARCHAR(32)) RETURNS INTEGER DETERMINISTIC BEGIN RETURN ROUND((CHAR_LENGTH(haystack) - CHAR_LENGTH(REPLACE(haystack, needle, ""))) / CHAR_LENGTH(needle)); END;