Search code examples
mysqlmatch-against

MySQL Match Against and Group by Multiple terms


I have data available appears in comments. The comments actually about skills like PHP, Java etc etc.

Now I want to use Match Against in such a way that I could find total records grouped by skills. So for instance if I match data against certain skills then data should be displayed as:

Skills    Total
..................
Java     10
PHP       5

Something like that.


Solution

  • http://www.sqlfiddle.com/#!2/fcea4/1

    SELECT skill, sum(comment REGEXP skill)
    FROM comments,skills
    GROUP BY skill