Can a Fulltext matching expression work inside a join condition
This is a related to another questio开发者_StackOverflown asked here: How to: match (search space) against (join with column from other table)
But I wanted to post this as a follow-up to one of the answers which the author said he had not tried, and to see if anyone could confirm it.
Sounds like you need to use a FULLTEXT matching expression in your join condition.
I've never used a fulltext match in a join condition, so I'm not sure this will work, but hypothetically this might do it:
SELECT DISTINCT c.* FROM corpuses c JOIN searches s ON (MATCH(c.title, c.body) AGAINST (s.term));
I just tried a query like that out of curiosity and it failed for a very clear reason:
AGAINST takes a string to search for, and an optional modifier that indicates what type of search to perform. The search string must be a literal string, not a variable or a column name. -MySQL Manual on fulltext searches (my emphasis)
Check out Bill Karwin's updated answer in the question you referenced to suggest a query using a subselect, which would select each row from table A that matches ANY value in a 'term' column from table B.
精彩评论