gpt4 book ai didi

mysql全文查询区别

转载 作者:行者123 更新时间:2023-11-29 00:32:51 24 4
gpt4 key购买 nike

我关注了this tutorial用于 mysql 全文搜索。

我有这张表:

CREATE TABLE IF NOT EXISTS `test` (
`id` int(20) NOT NULL AUTO_INCREMENT,
`textrow` varchar(256) NOT NULL,
PRIMARY KEY (`id`),
FULLTEXT KEY `textrow` (`textrow`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;

INSERT INTO `test` (`id`, `textrow`) VALUES
(1, 'Agajan Torayev'),
(2, 'torayeff');

ALTER TABLE test ADD FULLTEXT(textrow);

这些查询之间有什么区别(一个给出零结果):

mysql> SELECT * FROM test WHERE MATCH(textrow) AGAINST('agajan');
Empty set (0.00 sec)

mysql> SELECT *, MATCH(textrow) AGAINST('agajan') FROM test;
+----+----------------+----------------------------------+
| id | textrow | MATCH(textrow) AGAINST('agajan') |
+----+----------------+----------------------------------+
| 1 | Agajan Torayev | 0 |
| 2 | torayeff | 0 |
+----+----------------+----------------------------------+
2 rows in set (0.00 sec)

最佳答案

不同之处在于,在第一个查询中,您使用匹配数据过滤结果,而在第二个查询中,您输出所有记录并添加一列以显示匹配ing 会导致。

虽然你没有得到结果,因为

A natural language search interprets the search string as a phrase in natural human language (a phrase in free text). [...] In addition, words that are present in 50% or more of the rows are considered common and do not match.

Taken from MySQL Full-Text Search Functions

关于mysql全文查询区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15729040/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com