我有查询Select * from table1 where name like '%Whateveruserpassintextbox%'
。
当用户在文本框查询中传递%
时返回所有表格数据。
处理这种情况的正确方法是什么?
最佳答案
尝试做 \%
匹配一个“%”字符。在 MySql Docs 上阅读更多内容
To test for literal instances of a wildcard character, precede it by the escape character. If you do not specify the ESCAPE character, “\” is assumed.
-----------------------------------------
| String | Description |
-----------------------------------------
| \% | Matches one “%” character |
| \_ | Matches one “_” character |
-----------------------------------------
关于mysql - 如何处理查询中的 %?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9426291/