Possible duplicate:
Split a string in SQL
Search for a comma separated column
In my PHP project, I have a problem writing SQL:
I have a β consultants β table with category fields that has values ββsuch as:
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + id | consultant_name | categories + +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 | AOAOAO | health,insurance,programming, + + 2 | BOBOBO | health,gaming,windows,mobile, + + 3 | CCCCCC | insurance,windows, + + 4 | DDDDDD | mobile, + + . | ...... | ............ + + . | ...... | ............ + + . | ...... | ............ + +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
And I have an array that contains all the categories with which a consultant can register.
$arrayOfCategories = $array("health","insurance","programming", "sports","gaming","windows","apple", "mobile","astrology");
What I want is an SQL query that should give me output, for example:
+++++++++++++++++++++++++++++++ + category | occurrence + +++++++++++++++++++++++++++++++ + health | 2 + + insurance | 2 + + programming | 1 + + sports | 0 + + gaming | 1 + + windows | 2 + + apple | 0 + + mobile | 2 + + astrology | 0 + +++++++++++++++++++++++++++++++
Any help would be appreciated ...
Thanks in advance...