php - 制作一个简单的搜索引擎php mysql

标签 php mysql

我有一个名为 tags 的下表 id|tag_title|post_id 和一个表 posts with id|title

我可以使用 fulltext 功能进行搜索,但这仅限于在 posts 表中搜索 title。 我想要的是同时在 tagsposts 表中搜索并获得最佳结果。 我怎样才能完成它...!!!

我的查询:

Select title from posts where Match(title) Against('$search' in boolean mode)

最佳答案

你可以试试:

SELECT title FROM posts WHERE Match(title) Against('$search' IN boolean mode)
UNION
SELECT title FROM posts INNER JOIN tags ON posts.id = tags.post_id WHERE Match(tag_title) Against('$search' IN boolean mode)

如果您想要更高级的东西,请查看 Apache Solr或 Apache Lucence

关于php - 制作一个简单的搜索引擎php mysql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23470467/

相关文章:

php - 使用 LEFT JOIN 时如何避免列名冲突

php - php中的mysql错误

php - 无论我做什么,相同的值都存储在 MySQL 表字段中

PHP SQL Join 查询合并多数组中的内容

c# - 当在 mysql 数据库中插入一行时收到通知

javascript - 为什么我的 ajax 请求得到响应 0?

php - Symfony:清除 Doctrine 缓存

php - 调用未定义的函数 curl_init().?

mysql - 我想在我的 charm 中为 MySQL db 添加一个关系并使用我的 charm 创建一些表

mysql从where子句获取总值和总数