Skip to content
Advertisement

Is there a way to use MySQL fulltext to search related tables?

I have a table called persons which contains data about, well, people. It also contains foreign keys to another table. I’d like to make a fulltext index that is able to search the related tables for full text.

Here is some sample data: (see http://sqlfiddle.com/#!9/036fc5/2)

So, I’d like to be able to search for persons from “Jersey”, such as:

But, of course, the text “Jersey” exists only in the states table and not in the persons table. Does it make sense to make a materialized/generated index? Is there a simpler way?

Advertisement

Answer

You need to put a separate full-text index on the states table, and join with that.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement