Home > Backend Development > PHP Tutorial > mysql查询问题,like的反向使用?

mysql查询问题,like的反向使用?

WBOY
Release: 2016-06-23 14:12:08
Original
1067 people have browsed it

mysql like

有没有这样的语句

比如

$str = "你好,今天你吃饭了吗?包子还是油饼啊?包子里边还有点维生素比油饼好";

数据库表t1里存的是 
id name
1  维生素
2  吃饭
3  运动
4  娱乐

用什么语句能匹配到用$str从t1中取到 维生素 和 吃饭 ?

回复讨论(解决方案)

MYSQL 里有一个LOCATE 函数

select * from t1 where find_in_set(name,$str)


SELECT * FROM t1 WHERE $str  LIKE CONCAT('%',name,'%');

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template