[英]mysql escape special 4 characters in my query
now i'm testing mysql escape special characters( \\,_,%,'
). 现在我正在测试mysql转义特殊字符(
\\,_,%,'
)。
-table real data- -表实际数据-
\test
_test
%test
'test
-my query- -我的查询-
1. 1。
select * from user_name where user_name LIKE '\test%' escape '|'
2. 2。
select * from user_name where user_name LIKE '_test%' escape '_' (underscope)
3. 3。
select * from user_name where user_name LIKE '%test%' escape '%'
4. 4。
select * from user_name where user_name LIKE ''test%' escape '''
but just first query is success result. 但只有第一个查询是成功的结果。 and just multiple escape was not running
只是没有逃跑
multiple escape query - 多重转义查询-
select * from user_name where user_name = '\\test%' escape ('|' || '%' || '_' || ''')
please advise for my query. 请为我的查询提供建议。 and i want to [insert value] just 4 case.
我想[插入值]仅4种情况。 (for example, under the 4 insert value not test case.
(例如,在4插入值下没有测试用例。
\\test
\_test
\%test
\'test
) )
You can use SQL LIKE
operator like below which will eventually match the special characters as well. 您可以使用如下所示的SQL
LIKE
运算符,该运算符最终还将与特殊字符匹配。 See a Live Demo Here 在这里观看现场演示
select * from user_name where user_name LIKE '%test%'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.