我曾尝试在我的 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 />';
}
您对优化查询和格式化搜索结果的输出有什么想法吗?