Jump to content
slj90

MATCH AGAINST (multiple columns)

Recommended Posts

I have a query that searches a single column

SELECT * FROM allmovies
        WHERE MATCH (all_title)
        AGAINST ('shrek' IN NATURAL LANGUAGE MODE);

However, I want to be able to search multiple columns

SELECT * FROM allmovies
        WHERE MATCH (all_title, all_tags, all_directors)
        AGAINST ('speilberg' IN NATURAL LANGUAGE MODE);

But that receives the error

#1191 - Can't find FULLTEXT index matching the column list

It works when searching each column individually, like above.

What is wrong with my query?

Thanks,

Share this post


Link to post
Share on other sites

The columns in the MATCH() must match the columns in the index definition.

You could either
 

...WHERE MATCH MATCH (all_title) AGAINST ('shrek' IN NATURAL LANGUAGE MODE) OR
         MATCH MATCH (all_tags) AGAINST ('shrek' IN NATURAL LANGUAGE MODE) OR
         MATCH MATCH (all_directors) AGAINST ('shrek' IN NATURAL LANGUAGE MODE) 

or

add a fulltext text index on (all_title, all_tags, all_directors)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.