这两个查询之间的区别

时间:2014-04-18 02:04:29

标签: mysql

我正在运行2个查询,这些查询应该显示相同的结果,

首先查询:

SELECT count( id ) AS cv FROM table_name WHERE field_name LIKE '%êêê01, word02, word03%'

第二次查询:

SELECT count( id ) AS cv FROM table_name WHERE match(field_name) against('êêê01, word02, word03')

但是第一个显示的行数多于第二个,有人可以告诉我为什么?

我在这个字段上使用全文索引

感谢。

1 个答案:

答案 0 :(得分:0)

我做了一个快速research,以下引用应该回答你的问题:

One problem with MATCH on MySQL is that it seems to only match against whole words so a search for 'bla' won't match a column with a value of 'blah'.

documentation for match

中也对此进行了描述

By default, the MATCH() function performs a natural language search for a string against a text collection. A collection is a set of one or more columns included in a FULLTEXT index. The search string is given as the argument to AGAINST(). For each row in the table, MATCH() returns a relevance value; that is, a similarity measure between the search string and the text in that row in the columns named in the MATCH() list.

同时like更强大,更强大。因为它可以看待个人角色:

Per the SQL standard, LIKE performs matching on a per-character basis, thus it can produce results different from the = comparison operator:

这解释了为什么like返回的结果多于match