Oracle 查询字符串包含连字符
我在 Oracle 上运行的查询应该允许连字符。结果应该与包括连字符的确切字符串匹配,如下所示:
SELECT <field>
FROM <table>
WHERE LOWER(field) LIKE '%-pa%';
但是结果显示“web-page”、“web -page”以及“web page”。但是,在这种情况下我只想找到“网页”和“网页”。我尝试用反斜杠转义连字符,但这导致找不到记录。有人可以给我一个关于如何进行这项工作的提示吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这不是我对 Oracle 如何处理连字符的观察。这是我所看到的简短示例:
您确定没有使用下划线而不是连字符吗?下划线是单个字符通配符。
That's not my observation of how Oracle treats hyphens. Here's a brief sample of what I see:
Are you sure you're not using the underscore instead of the hyphen? The underscore is a single character wild card.
通常连字符不需要转义,但你可以尝试
代替“X”,你可以使用任何任意字符
Normaly the hyphen shouldn't need to be escaped, but you can try
instead of 'X', you can use any arbitrary character