我有 3 个表,t1、t2 和 t3,如下所示:
t1
___
t1id
name
address
type
t2
___
t2id
title
t3
____
t3id
t1id
t2id
我有一个关于 t1 的全文索引,涵盖name
、address
和type
。
我必须做什么才能使以下查询起作用?只是添加全文索引是t2.title
行不通的,对吗?
SELECT t1.id, t1.name,MATCH(t1.name,t1.address,t1.type,t2.title) AGAINST ('query') as rank
FROM t1
LEFT OUTER JOIN t3 ON t1.t1id = t3.t1id
LEFT OUTER JOIN t2 ON t3.t2id = t2.t2id
WHERE MATCH(t1.name,t1.address,t1.type,t2.title) AGAINST('query' IN NATURAL LANGUAGE MODE WITH QUERY EXPANSION)
HAVING rank > 0.2
ORDER BY rank DESC