下划线在类似 oracle 的子句中不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21380261/
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
Underscore is not working in oracle like clause
提问by Ramesh
When development, I used 'test_1%' to find 'test_123' in like. But in production environment its not working. Using 'escape '\'' is working. is there any setting needs to set in oracle? I want to use without escape '\''.
开发时,我用'test_1%'在like中找到'test_123'。但是在生产环境中它不起作用。使用 'escape '\'' 是有效的。oracle 有什么设置需要设置吗?我想不转义地使用'\''。
回答by Hamidreza
try this in SQL Developer:
在 SQL Developer 中试试这个:
SELECT * FROM TABLE1 WHERE NAME LIKE 'test\_1%' escape '\'
in sql plus:
在 sql plus 中:
set escape '\'
SELECT * FROM TABLE1 WHERE NAME LIKE 'test\_1%';
回答by Sohail xIN3N
In Oracle, you can also use ESCAPE
like this:
在 Oracle 中,您还可以ESCAPE
这样使用:
SELECT * FROM name_of_table WHERE description LIKE 'testing\_%' ESCAPE '\';
回答by laughsloudly
The other answers using the ESCAPE '\'
didn't work for me, but I was able to overcome this issue by using a REPLACE function:
使用 的其他答案ESCAPE '\'
对我不起作用,但我能够通过使用 REPLACE 函数克服这个问题:
SELECT * FROM name_of_table WHERE REPLACE(description, '_', '~') LIKE 'testing~%';