【问题标题】:MySQL: how to make multiple table fulltext searchMySQL:如何进行多表全文搜索
【发布时间】:2010-03-04 10:14:49
【问题描述】:

我想在我的 PHP 站点中集成 MySQL 全文搜索功能。

我现在有以下问题。

SELECT *
FROM testtable t1, testtable2 t2
WHERE MATCH (
t1.firstName, t1.lastName, t1.details, t2.firstName, t2.lastName, t2.details
)
AGAINST (
'founder'
);

我有错误代码:

#1210 - Incorrect arguments to MATCH

你知道为什么以及如何解决它吗?

非常感谢!

编辑:

我采用RageZ的方法:

SELECT *
FROM testtable t1, testtable2 t2
WHERE MATCH (
t1.firstName, t1.lastName, t1.details
)
AGAINST (
'founder'
) OR MATCH( t2.firstName, t2.lastName, t2.details) AGAINST (
'founder'
); 

我有一个新问题。如果我想查找以下内容:

AGAINST('founder', 'initiator', 'employee');

如何编写查询?

好的,我知道反对只能有一个标准。

AGAINST('founder');

【问题讨论】:

    标签: mysql full-text-search


    【解决方案1】:

    我认为由于全文搜索使用一些特定的索引,你应该用OR分隔表格

    SELECT *
    FROM testtable t1, testtable2 t2
    WHERE MATCH (
    t1.firstName, t1.lastName, t1.details
    )
    AGAINST (
    'founder'
    ) OR MATCH( t2.firstName, t2.lastName, t2.details) AGAINST (
    'founder'
    ); 
    

    【讨论】:

    • 对我来说闻起来像笛卡尔积(但是,我没有“匹配/对抗”的经验)......不应该有一个“限制”(又名加入)来证明这一点吗?
    • @thanks RageZ,如果 AGAINST 中的元素是多个,如何处理?
    • 你必须多次复制模式
    • @lexu:错误消息是关于反对不正确的语法。如果mysql会发疯,我会像你一样打赌;-)
    【解决方案2】:
    AGAINST('founder initiator employee');
    

    或者您可以使用boolean mode 来获取更多好东西

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-15
      • 2023-04-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-25
      相关资源
      最近更新 更多