【问题标题】:MYSQL match against query two tablesMYSQL 匹配查询两个表
【发布时间】:2012-06-05 02:18:58
【问题描述】:

是否可以使用连接对包含两个表的查询进行匹配?棘手的部分可能是表上的索引,但也许有办法.. sql 不是我的强项。非常感谢。我想可能是这样的:

SELECT * FROM 'pages' p
LEFT JOIN `tags` t
ON p.id = u.pageid
WHERE MATCH(p.shdescript,t.tag) AGAINST ('romance, relationship')

非常感谢

【问题讨论】:

标签: mysql join match against


【解决方案1】:

这是可能的,但你需要有文本索引。

mysql> alter table pages add fulltext index_text(shdescript);

mysql> alter table tags add fulltext index_text(tag);

SELECT * FROM 'pages' p
LEFT JOIN `tags` t
ON p.id = u.pageid
WHERE MATCH(p.shdescript,t.tag) AGAINST ('romance relationship')

我想这已经足够了。

编辑:

从 MySQL 5.6 开始,上述全文搜索可以在 MyISAM 和 InnoDB 存储引擎上完成。在早期的 MySQL 版本中,只有 MyISAM 表支持全文索引。

http://dev.mysql.com/doc/refman/5.6/en/fulltext-search.html

【讨论】:

猜你喜欢
  • 2013-06-10
  • 1970-01-01
  • 2019-03-13
  • 2012-07-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多