I am trying to construct a complex query. I have a table, and in that table, I would like to add an artificial field, match_count, using SELECT *,match_count FROM. That’s not the problem. The problem is this: I have several regular expressions, and I would like to increase the match_count with each regular expressions found. These expressions are to be applied to several fields of the table, like param1 REGEXP "reg1" and param2 REGEXP "reg2", and param1 REGEXP "reg3". Columns can be re-used, as can be the expressions, but the match_count field should correspond to the number of matches.
If possible, it would also be cool if, if a column matches a regular expression several times, the match count were increased not by one, but by the number of these matches.
You can sum the results of the REGEXP expressions:
I don’t think it’s possible in MySQL. It is however possible in many general purpose languages.