Oracle 使用 contains 关键字选择所有行
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1783303/
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
Oracle select all rows using the contains keyword
提问by Marco
I'm looking for a character that I can use in an Oracle contains to get ALL results.
我正在寻找一个可以在 Oracle 包含的字符中使用以获取所有结果的字符。
If I search for the string "test" in a title column I use this statement:
如果我在标题栏中搜索字符串“test”,我将使用以下语句:
select *
from my_table
where contains (title,
'<query><textquery grammar="CTXCAT">test</textquery></query>') > 0
With this statement I get the rows which have the "test"-string included in title-column.
通过这个语句,我得到了标题列中包含“测试”字符串的行。
BUT: Is there any way to use contains and select ALL rows?
但是:有什么方法可以使用包含并选择所有行?
回答by Galghamon
Would this work for you?
这对你有用吗?
select * from my_table
where title like
'<query><textquery grammar="CTXCAT">%</textquery></query>'
This uses the LIKE syntax and the % wildcard to achieve what I think you want.
这使用 LIKE 语法和 % 通配符来实现我认为你想要的。
回答by Bill Karwin
The documentation says wildcards with the Oracle Text CONTAINS()
predicate are %
and _
just like the LIKE
predicate.
该文件说,与Oracle Text的通配符CONTAINS()
谓词是%
与_
就像LIKE
断言。
Does the following work? I don't have an instance of Oracle handy to test.
以下是否有效?我没有方便测试的 Oracle 实例。
select *
from my_table
where contains (title,
'<query><textquery grammar="CTXCAT">%</textquery></query>') > 0