MySQL REGEXP usage within Boolean Match/Against

I have the following MySQL query:

SELECT title, description FROM some_table WHERE MATCH (title,description) AGAINST ('+denver (REGEXP "[[:<:]]colorado[s]*[[:>:]]")' IN BOOLEAN MODE);

the "regexp" here looks for a "complete word" colorado (with or without the ending "s").

I want to actually select only those rows that have ("denver") AND ("colorado" or "colorados"). But I cannot put a "+" for the REGEXP. I tried but got 0 results, although there are rows in the table that match the requirement.

Any ideas on how I can get the "+" to work within against using a REGEXP? I am constructing this from within a PHP script where "denver" and "colorado" are values of variables I use to construct the select statement.

My PHP/MySQL script would look somewhat like this:

SELECT title, description FROM some_table WHERE MATCH (title,description) AGAINST ('+$var1 (REGEXP "[[:<:]]$var2[s]*[[:>:]]")' IN BOOLEAN MODE);


I don't think it's possible to combine regular expressions and MATCH ... IN BOOLEAN MODE. You need to use the syntax for writing boolean expressions.

  • Boolean Full-Text Searches
  • Try something like this:

    SELECT title, description
    FROM some_table
    WHERE MATCH (title,description)
          AGAINST ('+denver +(colorado colorados)' IN BOOLEAN MODE);
    
    链接地址: http://www.djcxy.com/p/75328.html

    上一篇: 如何链接2个MySQL数据库与bash脚本

    下一篇: MySQL布尔匹配/反对中的REGEXP用法