如何在 Oracle SQL Developer 中转义下划线?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42946040/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to escape underscores in Oracle SQL Developer?
提问by RedSea
If I want to select strings with underscores using Oracle SQL Developer, how do I have to escape those?
如果我想使用 Oracle SQL Developer 选择带下划线的字符串,我该如何转义这些字符串?
I tried:
我试过:
name like '%_%'
name like '%'_%'
name like '%\_%'
but none of this helped.
但这些都没有帮助。
回答by Aleksej
You need to use the explicit escape
; in this way you can decide a character to use for escaping and then use it in your LIKE
.
您需要使用显式escape
; 通过这种方式,您可以决定用于转义的字符,然后在您的LIKE
.
For example, here I use the '!'
to escape special characters:
例如,这里我使用'!'
来转义特殊字符:
select str
from (
select 'a_b' str from dual union all
select 'ab' from dual
)
where str like '%!_%' escape '!'
gives
给
STR
---
a_b