MySQL查询"LIKE"什么都不返回 [英] MySQL QUERY "LIKE" returns nothing

查看:200
本文介绍了MySQL查询"LIKE"什么都不返回的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用MySQL 5.0.51a版和PHP版本访问数据库,当该查询应返回至少两个与LIKE条件匹配的行时,该查询不返回任何内容.

I'm using MySQL version 5.0.51a and PHP to access the database, and this query returns nothing when it should return at least 2 rows which match the LIKE condition.

$result = mysql_query("SELECT * FROM user WHERE name LIKE '%".$search."%'OR email LIKE    '%".$search."%' ORDER BY ".$order, $con);

$ search 变量为"名称",

ORDER,$ order或$ con都没有问题,我已经尝试过了,并且有2行名称为"Name",但不知何故找不到这些行,它什么也不返回.

there is no problem with ORDER, $order or $con, i've already tried that, and there are 2 rows where the name is 'Name', but somehow it can't find those rows and it returns nothing.

有人知道问题出在哪里吗?

Does anybody know where the problem is?

推荐答案

尝试删除双逗号

$result = mysql_query("
                    SELECT 
                        * 
                    FROM user 
                    WHERE name LIKE '%{$search}%' OR email LIKE '%{$search}%' 
                    ORDER BY ".$order, $con);

这篇关于MySQL查询"LIKE"什么都不返回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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