用单引号搜索文本 [英] Search a text with single quote

查看:44
本文介绍了用单引号搜索文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如我有一个单词列表:men's package、moment、非常如何在 mysql 示例文本中搜索:men's"并仅返回men's package"

For example I have a list of words: men's package, moment, immensely How can I search in mysql sample text: "men's" and return only "men's package"

我正在使用这个$str = str_replace("s", "%s", $str);

I'm using this $str = str_replace("s", "%s", $str);

如果我搜索男士",它只会显示:男士包

If I search for "men's", it will only show: men's package

但是当我搜索男士"时它还将显示:男士包,时刻,非常

but when I search for "mens" it will also show: men's package, moment, immensely

推荐答案

我不太明白你的字符串替换函数在做什么,但是 sql 通配符呢?

I don;t really understand what your string replace function is doing, but what about sql wildcards?

SELECT * FROM <table>
WHERE <field> LIKE '%men%'

这将返回以男性开头的任何内容.您可以将通配符放在开始、结束、中间、任何地方!

this will return anything starting with men. You can put the wildcard symbol at the start, end, middle, anywhere!

如果这就是你在字符串替换中所做的,那么忽略这个!

If that's what you're doing in the string replace then ignore this!

这篇关于用单引号搜索文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆