Underscore is not working in oracle like clause

£可爱£侵袭症+ 提交于 2019-12-17 19:33:15

问题


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 '\''.


回答1:


try this in SQL Developer:

SELECT * FROM TABLE1 WHERE NAME LIKE 'test\_1%' escape '\'

in sql plus:

set escape '\'
SELECT * FROM TABLE1 WHERE NAME LIKE 'test\_1%';



回答2:


In Oracle, you can also use ESCAPE like this:

SELECT * FROM name_of_table WHERE description LIKE 'testing\_%' ESCAPE '\';



回答3:


The other answers using the ESCAPE '\' didn't work for me, but I was able to overcome this issue by using a REPLACE function:

SELECT * FROM name_of_table WHERE REPLACE(description, '_', '~') LIKE 'testing~%';


来源:https://stackoverflow.com/questions/21380261/underscore-is-not-working-in-oracle-like-clause

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!