我正在尝试跨多个产品表进行全文搜索;例如制造商名称,产品型号名称,产品类别名称等。
我正在使用MariaDB 10.3,已在所有相应的* .name列上启用了全文,并且我正在使用innodb引擎
SELECT f.id AS family_id,
f.name AS family_name,
mr.id AS manufacturer_id,
mr.name AS manufacturer_name,
mm.id AS model_id,
mm.name AS model_name,
mm.year AS model_year
FROM product_manufacturer mr
LEFT JOIN product_family f ON
f.manufacturer_id=mr.id
LEFT JOIN `product_model` mm ON
f.id=mm.product_family_id
WHERE
MATCH (mr.name) AGAINST ('TestProduct' IN NATURAL LANGUAGE MODE)
^^可行
但是,如果我要开始添加OR条件或开始在连接的列上进行搜索,我将收到整个数据集,就好像根本没有条件,如下面的2个查询所示
SELECT f.id AS family_id,
f.name AS family_name,
mr.id AS manufacturer_id,
mr.name AS manufacturer_name,
mm.id AS model_id,
mm.name AS model_name,
mm.year AS model_year
FROM product_manufacturer mr
LEFT JOIN product_family f ON
f.manufacturer_id=mr.id
LEFT JOIN `product_model` mm ON
f.id=mm.product_family_id
WHERE
MATCH (mr.name) AGAINST ('TestProduct' IN NATURAL LANGUAGE MODE)
SELECT f.id as family_id,
f.name as family_name,
mr.id as manufacturer_id,
mr.name as manufacturer_name,
mm.id as model_id,
mm.name as model_name,
mm.year as model_year
FROM product_manufacturer mr
LEFT JOIN product_family f on
f.manufacturer_id=mr.id
LEFT JOIN `product_model` mm on
f.id=mm.product_family_id
WHERE
MATCH (mm.name) AGAINST ('TestProduct' IN NATURAL LANGUAGE MODE)
OR MATCH (mr.name) AGAINST ('TestProduct' IN NATURAL LANGUAGE MODE)