简体   繁体   English

Mysql匹配,反对没有返回正确的结果

[英]Mysql match, against is not returning proper results

I am trying this query: 我正在尝试这个查询:

SELECT * FROM `table_name` WHERE MATCH(`field_name`)
AGAINST('+san +city' IN BOOLEAN MODE)

I want to get all records that should contain san city, but the result is different. 我想得到应该包含san city的所有记录,但结果是不同的。 In result am getting all records that contain "city" like "Pearl City, Salt lake city etc". 结果我得到所有包含“城市”的记录,如“珍珠城,盐湖城等”。 What I am doing wrong. 我做错了什么。

Try adding the MATCH in your SELECT -part of your query to get a grip on how MySQL works here: 尝试在SELECT -part查询中添加MATCH,以掌握MySQL的工作方式:

SELECT *, MATCH(field_name) AGAINST('+san +city' IN BOOLEAN MODE)
FROM table_name 
WHERE MATCH(field_name) AGAINST('+san +city' IN BOOLEAN MODE)

You will see the priority in this column. 您将在此列中看到优先级。

Keep in mind that your results differ if you're using MyISAM and MySQL < 5.6 or InnoDB and MySQL => 5.6. 请记住,如果您使用的是MyISAM和MySQL <5.6或InnoDB和MySQL => 5.6,则结果会有所不同。 Here's a good article about it. 这是一篇关于它的好文章

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM