MYSQL KEYWORD MATCH query on two columns from different tables?


Is it possible to perform a  MATCH keyword search on a column from one table with another column from a second table (these two tables are joined on an ID).

Table A
PK - an_ID

Table B
FK -  an_ID

Both Title and Content are TEXT fields.
Both have had a FULLTEXT search added to their respective table.

Is there one query which will search the 'Title' and/or the 'Content' for a Match against a keyword search?

I have tried:

SELECT *, MATCH( title, content ) AGAINST('keyword%') AS score FROM Table_A t1 INNER JOIN Table_B t2 ON t1.an_ID = t2.an_ID WHERE MATCH( title, content ) AGAINST('keyword%')

I get incorrect arguments to MATCH :(

Any ideas?

Hope that is clear?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Have you tried:

SELECT t1.*, MATCH( t1.title, t1.content ) AGAINST('keyword%') AS score FROM Table_A t1 INNER JOIN Table_B t2 ON t1.an_ID = t2.an_ID WHERE MATCH( t2.title, t2.content ) AGAINST('keyword%')
bigMlittleCAuthor Commented:
I have tried that. Still the same error: incorrect match.

(expect I tried it as t1.title, t2.content) as title is in table A (t1) and content is in table B (t2)
As far as I know you cannot span multiple full-text indexed columns in different tables for MATCH.  You need to specify the columns exactly as they were defined when you created the index.  You will need to restructure your database to have the two columns together in one table, then create a one full-text index that has the two columns i.e. alter tablename add fulltext index (title, content);

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

bigMlittleCAuthor Commented:
I have a feeling you could be right.
bigMlittleCAuthor Commented:
No other suggestion so will close as I think johanntagle is right
Ray PaseurCommented:
I think you're getting good advice here, but you might also consider something with nested queries like SELECT ... WHERE IN(SELECT...) -- my guess is that you would want to make the IN query be against the title if it is the smaller of the two columns.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.