使用LIKE在MYSQL查询中无法使用两个单词和空格 [英] two words and blank spaces not working in MYSQL query using LIKE

查看:649
本文介绍了使用LIKE在MYSQL查询中无法使用两个单词和空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的网站进行搜索,并且可以通过一个单词查询正常工作

i'm making a searcher for my site and this works fine with one word querys

 $consulta = mysql_query("SELECT * FROM recetas WHERE (titulo LIKE '%$busqueda%' OR intro LIKE '%$busqueda%' OR extra LIKE '%$busqueda%') ORDER BY id DESC");

但是,如果我键入两个单词",它不会给我结果,而$busqueda是来自通过$_POST['TERM']

But if i type 'two words' it doesn't give me result, $busqueda it's result from a <input/> given through $_POST['TERM']

知道我想念什么吗?

已解决

我没有将变量编码为URI ...哎呀,谢谢!

i was missing to encode the variable to URI... oops haha THANKS!

推荐答案

考虑查询的结尾如何:

Select ... where '%two words%. ...

如果您要搜索类似的单词,则必须对数据进行整理以使其看起来更像:

If you want to search for words like that, you'll have to massage the data to look more like:

 ... Like '%two%words%'
 ... Like '%two%' or like '%words%'

取决于您的确切搜索要求

depending on your exact search requirements

这篇关于使用LIKE在MYSQL查询中无法使用两个单词和空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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