我正在运行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')
但是第一个显示的行数多于第二个,有人可以告诉我为什么?
我在这个字段上使用全文索引
感谢。
答案 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'.
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
。