在mySQL数据库中搜索%20

时间:2011-07-24 09:59:05

标签: mysql phpmyadmin

我正在尝试通过phpmyadmin在我的数据库中搜索包含%20的所有行。这是我的疑问:

select * from `jos_picmicro_content` where `introtext` like '\%20' escape '\';

除了它返回以下错误:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''\'' at line 1

我做错了什么?

4 个答案:

答案 0 :(得分:5)

您已逃过'。正确的语法是:

select * from `jos_picmicro_content` where `introtext` like '\%20' escape '\\';

为了快速识别问题,请将查询划分为不同的行,例如:

select * from `jos_picmicro_content` 
where `introtext` 
like '\%20' 
escape '\\';

然后MySQL将警告问题在哪一行。

答案 1 :(得分:2)

这可能与MySQL对\字符的非标准用法有关。但您可以使用ESCAPE关键字指定任何字符:

select * 
from jos_picmicro_content 
where introtext like '@%20' escape '@';

但是除了exotext 正好 '%20'的行之外,这仍然不会返回任何内容,您仍然需要使用通配符在该列的任何位置查找%20

select * 
from jos_picmicro_content 
where introtext like '%@%20%' escape '@';

答案 2 :(得分:0)

您可以删除查询的escape '\';部分,因为默认的MySQL转义符是'\'。但是如果你真的需要escape部分,那么你必须输入它:

escape '\\';

或者

escape '\\\\';

答案 3 :(得分:0)

你有没有尝试过:

jos_picmicro_content中选择*,其中introtext喜欢'%\%20%'

相关问题