Php 按特殊字符搜索

Php 按特殊字符搜索,php,mysql,sql,Php,Mysql,Sql,在我们的表中,包含名为description的列 “说明”列包含以下值 test,%test,test% 如果我将%test作为搜索字符串的输入,那么它将的“test”、“test”、“test%”作为结果。但是我只想要%test”作为结果。%是一个特殊字符,需要转义() 请尝试“\%test” 片段: select description from tablename where decription like '\%test' 张贴您在问题中使用的查询。如果你不提供任何信息,谁能帮助你呢?

在我们的表中,包含名为description的列

“说明”列包含以下值

test
%test
test%


如果我将
%test
作为搜索字符串的输入,那么它将
的“test”、“test”、“test%”作为结果。但是我只想要
%test”
作为结果。

%是一个特殊字符,需要转义()

请尝试“\%test”

片段:

select description from tablename where decription like '\%test'

张贴您在问题中使用的查询。如果你不提供任何信息,谁能帮助你呢?现在我使用动态字符串。所以我使用了addcslahes(mysql\u real\u escape\u string(“input\u string”,“%?*…”)。很高兴听到!!你能接受我的回答吗?(感谢Rat-a-tat-a-tat Ratatouille提供的片段)!