I have table like this:
-----------
ID | Value
-----------
1 | AAAA
2 | ABCD
3 | AADC
4 | ABBD
I am trying to figure out how to return the number of times a string occurs in each of the Value.
So, if I want to count of time 'A' and 'B'appears, the sql statement will return like this:
-------------------
ID | Value | Count
-------------------
1 | AAAA | 0
2 | ABCD | 1
3 | AADC | 0
4 | ABBD | 2
5 | ABBB | 3
6 | AABB | 3
7 | AAAB | 3
8 | AABC | 2
9 | DBCA | 1
10 | CBAA | 2
11 | BDAB | 2
Example: The value is "ACBB" and the chars I want to search is 'A' and 'B'. And the result is 2. First we search 'A' and 'B'. When we replace first 'A' and 'B', the value will be "CB" ('C' and 'B') and the counter will be 1. If there is one more 'A' or 'B', it will be count. So the counter for the example is 2, because there is one 'B'. If there is 2 'B', the result is 3.
Is there any way to do this? I do not want to use php, vb, etc. Just MySQL