MySQL - 查找子字符串并从整个句子中仅选择255个字符

时间:2014-01-19 17:20:32

标签: mysql regex

我正在尝试从文本中选择最多255个字符,并仅返回包含用户正在查找的匹配单词的子字符串或第一个字符串。

这是我网站中搜索引擎的脚本,其中结果仅预览包含用户正在搜索的单词集的帖子。

Here is an example for a preview:

  A user type in search box "manufacturing companies"

 ...visited the campus to announce the creation of a new public-private **Manufacturing** Innovation Institute that will soon take up residence at NC State. Eighteen **companies** headquartered in North Carolina will partner...

In case there are more coincidences, select only the substring that contains more words matched.

How can I accomplish this within a query?

感谢。

0 个答案:

没有答案