Forum Moderators: open
example: i want to search for the word "word1" on this string:
"word1 test test test string2 word1 string3 word1"
The result should be 3 since there were 3 "word1" on that string..
Its like returning the number of words that that string has...
thanks.. appreciate.. =)
SELECT (LENGTH(yourfield)-LENGTH(REPLACE(yourfield,yourword,'')))/LENGTH(yourword)
FROM yourtable
It should be clear how this works - it also should be clear that it fails when "yourword" is a substring of another word.
There's probably a very elegant and more accurate method using regular expressions.