简体   繁体   English

MATCH(字段1,字段2)和MATCH(字段1)或MATCH(字段2)之间的区别

[英]Difference between MATCH (field1, field2) and MATCH(field1) OR MATCH(field2)

Is there a difference in results between the two below queries? 以下两个查询的结果之间有区别吗?

SELECT *
FROM table1, table2
WHERE
    ( MATCH(table1.row1) AGAINST('searchstring' IN BOOLEAN MODE) )
    OR
    ( MATCH(table2.row2) AGAINST('searchstring' IN BOOLEAN MODE) )


SELECT *
FROM table1, table2
WHERE
    ( MATCH(table1.row1, table2.row2) AGAINST('searchstring' IN BOOLEAN MODE) )

I prefer the first approach, as that makes it more easy for me to implement ranking criteria for each field. 我喜欢第一种方法,因为这使我更容易实现每个领域的排名标准。

Yes, the second query is an error. 是的,第二个查询是错误。

The MATCH() function's arguments must be all the columns for which one fulltext index is defined. MATCH()函数的参数必须是为其定义了一个全文索引的所有列。

But indexes cannot be defined over multiple tables. 但是不能在多个表上定义索引。 Therefore an exppression like MATCH(table1.row1, table2.row2) can't work, because it references columns from two different tables. 因此,像MATCH(table1.row1, table2.row2)这样的MATCH(table1.row1, table2.row2)无法工作,因为它引用了来自两个不同表的列。


If you reference only columns from the same table, then it's okay to put multiple columns in a MATCH() function. 如果仅引用同一表中的列,则可以将多个列放在MATCH()函数中。 In fact, it's mandatory if the fulltext index was defined over multiple columns. 实际上,如果全文索引是在多个列上定义的,则是强制性的。 Note that above, I said that the function's arguments must be all columns for a fulltext index. 请注意,上面我说过,函数的参数必须是全文索引的所有列。

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

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