php - 从描述中搜索单词并返回从该单词开始的描述

标签 php mysql

是否有任何功能可以从描述中搜索单词并返回从该单词开始或仅返回该搜索单词之前的单词的描述?

如果这是描述..

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.

我想搜索“打印”这个词。结果必须像这样显示..

printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s

或者

the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s

结果将显示我正在搜索的单词或仅搜索单词之前的一个单词。

最佳答案

您应该在此处阅读有关 MySQL 内置函数的信息: http://dev.mysql.com/doc/refman/5.7/en/string-functions.html

SELECT SUBSTRING(description FROM LOCATE('printing', description))
...

关于php - 从描述中搜索单词并返回从该单词开始的描述,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40200301/

相关文章:

php - 查找每小时的行数

mysql - 在golang中如何支持多种sql语法(mysql vs postgres)

php - WordPress 查询。正确引用页面摘录?

php - 如何修复 "load column of a database with double click on a td tag with jquery in a drop down menu"

javascript - Google 条形图 - 如何使用 JSON 为每个条目获取 2 个不同的条形图

javascript - 在 Blade foreach 循环中使用 JS 动态更改 div CSS 背景

mysql - 获取MySQL中的不同列

java - 基于访问的重定向

php - 未通过中间件时来自节流请求的 TypeError

mysql - Inner Join 在一个棘手的环境中,更新 Sql Fiddle,问题已隔离,正在寻找解决方案?