سؤال

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.

Try something like this:

SELECT title, description
FROM some_table
WHERE MATCH (title,description)
      AGAINST ('+denver +(colorado colorados)' IN BOOLEAN MODE);
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top