Oracle查询字符串,包括连字符 [英] Oracle query String including hyphen character
问题描述
我查询了我在Oracle上运行的查询,该查询应该允许连字符.结果应该与包括连字符在内的确切String匹配,如下所示:
I have query that I run on Oracle that is supposed to allow hyphen characters. The results are supposed to match the exact String including the hyphen character as follows:
SELECT <field>
FROM <table>
WHERE LOWER(field) LIKE '%-pa%';
但是结果显示为网页",网页"以及网页".但是,在这种情况下,我只想找到网页"和网页".我试图用反斜杠转义连字符,但未找到任何记录.有人可以给我提示如何做这项工作吗?
The results however show "web-page", "web -page" as well as "web page". However, I only would like to find "web-page" and "web -page" in this case. I tried to escape the hyphen character with a backslash but that results in no records found. Can anybody give me a hint on how to make this work?
推荐答案
这不是我对Oracle如何处理连字符的观察.这是我所见的简短示例:
That's not my observation of how Oracle treats hyphens. Here's a brief sample of what I see:
SQL> select * from fb;
ID
----------
Web-Page
Web Page
Web -Page
SQL> select * from fb where lower(id) like '%-pa%';
ID
----------
Web-Page
Web -Page
确定要使用下划线而不是连字符吗?下划线是单字符通配符.
Are you sure you're not using the underscore instead of the hyphen? The underscore is a single character wild card.
这篇关于Oracle查询字符串,包括连字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!