【发布时间】:2015-12-11 07:12:30
【问题描述】:
我正在对 MySQL 数据库中的静态记录执行关键字文本搜索。是否可以构造一个查询来查找记录中的第一个关键字和相邻记录中的第二个关键字?考虑以下示例数据。
------------------------------------------------------
| id | textstrings |
------------------------------------------------------
| 1 | Every good boy does fine. |
| 2 | The quick brown fox jumped over the lazy dog. |
| 3 | I will not eat green eggs and ham. |
| 4 | There is no time like the present. |
| 5 | Envy is an ugly shade of green. |
------------------------------------------------------
搜索词条 green brown 应返回记录 2 和 3,因为它们是相邻记录,但不应包含记录 5,因为它不是与记录 3 相邻的。
我知道我可以对任一单词执行查询并通过处理结果集来完成此操作,但我想知道是否可以将其构建到查询中。
这个字段确实有一个 FULLTEXT 索引。
【问题讨论】:
标签: php mysql distance levenshtein-distance