Mysql全文搜索:到where子句,还是不到where子句?
我有 2 个 mysql 全文搜索查询,它们返回一组不同的结果。
SELECT e.id AS e__id,
MATCH(e.subtitle, e.summary, e.title, e.prtext) AGAINST ('lorem')
FROM exhibitions e
将返回一组可预测的 7 行(表中总共有 10 行),每行都有包含单词“lorem”的记录的 id。
但是,当我引入 where 子句时,
SELECT e.id
FROM exhibitions e
WHERE MATCH(e.subtitle, e.summary, e.title, e.prtext) AGAINST ('lorem')
不会返回任何行。
这两个查询有什么区别?
I have 2 mysql fulltext search queries that return a different set of results.
SELECT e.id AS e__id,
MATCH(e.subtitle, e.summary, e.title, e.prtext) AGAINST ('lorem')
FROM exhibitions e
will return a predictable set of 7 rows (I have 10 overall in the table), each having the id of a record that contains the word 'lorem'.
However, when I introduce a where clause
SELECT e.id
FROM exhibitions e
WHERE MATCH(e.subtitle, e.summary, e.title, e.prtext) AGAINST ('lorem')
No rows are returned.
What is the difference between these two queries?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试在布尔模式下添加 *
try adding * IN BOOLEAN MODE
实际上,问题是我的表结构上有许多全文索引,而我实际上只需要一个索引。以下是带有
where
和and
子句的正确查询:Actually, the issue was I had a number of fulltext indicies on my table structure, when I really only needed one. Here is a correct query with a
where
and anand
clause: