在 Mysql 中搜索一个词并从字符串(非完整字符串)中获取预测搜索词

Search a word and Get Predictive Search Words from String (not complete string) in Mysql

我有 SQL Table 如下所示的设计

*-----------------------------------------
| id | title                              |
| -- | -----------------------------------|
| 1  | This is nice pen looking good      |
| 2  | This is nice pen looking elegent   |
| 3  | This is nice pen looking great     |
| 4  | This is nice pen looking best.     |
------------------------------------------

示例查询:Select * from table where title LIKE '%looking%'

当我尝试使用 (如查询) 或使用 (正则表达式)搜索词 "looking" 就像示例查询一样,我得到了下面提到的完整字符串结果

结果

*------------------------------------
| title                              |
| -----------------------------------|
| This is nice pen looking good      |
| This is nice pen looking elegent   |
| This is nice pen looking great     |
| This is nice pen looking best.     |
-------------------------------------

我想要什么?

我要预测搜索词(不完整的字符串)

如何使用 SQL.

通过搜索词(查找)获得下面提到的结果
*-------------------
| title             |
| ------------------|
| looking good      |
| looking elegent   |
| looking great     |
| looking best.     |
--------------------

请建议我如何编写查询以获得这些类型的结果? 谢谢

您可以使用substring_index()获取下一个作品:

Select t.*,
       substring_index(substring_index(concat(' ', title, ' '), ' looking ', -1), ' ', 1) as next-word
from table
where title LIKE '%looking%';

Here 是一个 db<>fiddle.