views:

695

answers:

2

Hi, I'm looking for a character which I can use in an oracle conatins to get ALL results.

If I search for the string "test" in a title-column I use this statement:

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: I there any way to use contains and select ALL rows?

A: 

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.

Galghamon
No, I need to use the contains keyword :(
Marco
Why can you only use the CONTAINS keyword? LIKE is the way to do it
thecoop
By using contains oracle is searching for each single word in any order.Btw: I tried "like" - just for testing - and it doesn't work for me.
Marco
+1  A: 

The documentation says wildcards with the Oracle Text CONTAINS() predicate are % and _ just like the LIKE predicate.

Does the following work? I don't have an instance of Oracle handy to test.

select * 
from my_table 
where contains (title, 
    '<query><textquery grammar="CTXCAT">%</textquery></query>') > 0
Bill Karwin
I checked the Oracle docs and % does work as a wildcard in text_query param of CONTAINS(). This is the right answer.
Dragos Toader
I tried this statement with "%" before and got an empty result table.
Marco