LMSouq
database Open

Count the number of occurrences of a string in a VARCHAR field?

GE
Geekman
1 month ago
3 views
Problem Description
I have a table like this: TITLE | DESCRIPTION ---------------|-------------------------------- test1 | value blah blah value test2 | value test test3 | test test test test4 | valuevaluevaluevaluevalue I am trying to figure out how to return the number of times a string occurs in each of the DESCRIPTION's. So, if I want to count the number of times 'value' appears, the sql statement will return this: TITLE | DESCRIPTION | COUNT ---------------|--------------------------------|----------- test1 | value blah blah value | 2 test2 | value test | 1 test3 | test test test | 0 test4 | valuevaluevaluevaluevalue | 5 Is there any way to do this? I do not want to use php at all, just mysql.

AI-Generated Solution

Powered by LMSouq AI · GPT-4.1-mini

✓ Solution Ready
Analyzing problem and generating solution…
Was this solution helpful?
Back to Knowledge Base