pheaselegen
pheaselegen

Reputation: 398

MATCH AGAINST multiple words AND OR

I am using fulltext search in a project. I want to search multiple words but i have a problem. So my query is;

SELECT MAX(id)
FROM table
WHERE MATCH (col1,col2) AGAINST ('+(word1) +(word2) +(word3 word4)')
GROUP BY col1
ORDER BY 1 desc limit 12

And this query is searches including word1 OR word2 OR word3 OR word4 but i want to search including word1 OR word2 OR word3 word4

So what is the solution?

Upvotes: 1

Views: 2258

Answers (2)

shyam sasi
shyam sasi

Reputation: 97

SELECT * FROM `user_profiles` 
WHERE MATCH (`first_name`,`last_name`) 
      AGAINST ('(+bruce+wayne)(+clark+kent)' IN BOOLEAN MODE)

Upvotes: -1

Ravi
Ravi

Reputation: 31407

You can try something like this one...

SELECT MAX(id) FROM table WHERE MATCH(colname1,colname2) AGAINST("keyword to search")  GROUP BY colname ORDER BY colname desc limit 12

Reference

Upvotes: 0

Related Questions