1

我曾尝试在我的 Intranet 中使用 mysql 全文搜索。我想用它在多个表中搜索,并根据结果页面中的表获取独立的结果。

这就是我为搜索所做的。

$query = "
        SELECT *
        FROM testtable t1, testtable2 t2, testtable3 t3
        WHERE match(t1.firstName, t1.lastName, t1.details) against(' ".$value."')
        or match(t2.others, t2.information, t2.details) against(' ".$value."')
        or match(t3.other, t2.info, t2.details) against(' ".$value."')
        ";

$result = mysql_query($query)or die('query error'.mysql_error());

while($row = mysql_fetch_assoc($result)){
    echo $row['firstName'];
    echo $row['lastName'];
    echo $row['details'].'<br />';
}

您对优化查询和格式化搜索结果的输出有什么想法吗?

4

1 回答 1

0

您不能fulltext index在多个表上创建一个。所以我fulltext index在每个表和or子句上都找到了一个(就像你一样)足够好。

但是,您可以创建一个视图(基于三个表)并针对该视图创建全文索引。

编辑:不幸的是,您不能在 Mysql 中的视图上创建索引

于 2010-03-08T10:47:45.190 回答