我有一个名为 tags
的下表
id|tag_title|post_id
和一个表 posts
with id|title
我可以使用 fulltext
功能进行搜索,但这仅限于在 posts
表中搜索 title
。
我想要的是同时在 tags
和 posts
表中搜索并获得最佳结果。
我怎样才能完成它...!!!
我的查询:
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/